Skip to content

Instantly share code, notes, and snippets.

View lcbasu's full-sized avatar
🐢
One step at a time.

Lokesh Basu lcbasu

🐢
One step at a time.
View GitHub Profile
@lcbasu
lcbasu / FirebaseImageService.java
Created June 17, 2020 01:32 — forked from m-cakir/FirebaseImageService.java
Spring Boot - File Upload to Firebase (Google Cloud)
import com.google.auth.oauth2.GoogleCredentials;
import com.google.cloud.storage.Blob;
import com.google.cloud.storage.Bucket;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.cloud.StorageClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.ConfigurationProperties;
@lcbasu
lcbasu / web-servers.md
Created February 6, 2019 05:12 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000

Become a next-generation systems hacker with Rust

[Rust] is a novel systems programming language, designed for writing and maintaining large-scale, ultra-reliable software in the domains where typically only C and C++ are appropriate. It is the only production programming language in the world that is memory safe - meaning Rust software does not segfault - but does not have a garbage collector or rely on reference counting, and that makes it suitable for writing all kinds of software. It is also arguably the fastest programming language in the world. And with a focus on developer

@lcbasu
lcbasu / generate-pushid.js
Created January 27, 2017 14:11 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage {
@lcbasu
lcbasu / UINavigationBarWithSubtitle.swift
Created July 14, 2016 19:22 — forked from nazywamsiepawel/UINavigationBarWithSubtitle.swift
UINavigationBar with subtitle / swift
func setTitle(title:String, subtitle:String) -> UIView {
var titleLabel = UILabel(frame: CGRectMake(0, -5, 0, 0))
titleLabel.backgroundColor = UIColor.clearColor()
titleLabel.textColor = UIColor.grayColor()
titleLabel.font = UIFont.boldSystemFontOfSize(17)
titleLabel.text = title
titleLabel.sizeToFit()

Most active GitHub users (git.io/top)

The count of contributions (summary of Pull Requests, opened issues and commits) to public repos at GitHub.com from Sun, 17 Mar 2013 12:08:02 GMT till Mon, 17 Mar 2014 12:08:02 GMT.

Only first 1000 GitHub users according to the count of followers are taken. This is because of limitations of GitHub search. Sorting algo in pseudocode:

githubUsers
 .filter((user) -> user.followers > 251)
@lcbasu
lcbasu / turing.coffee
Created November 28, 2012 07:01 — forked from jamesrcounts/turing.coffee
A turing machine in coffeescript
alert = (s) -> console.log s
createResult = (state, symbol, direction) ->
nextState: state
writeSymbol: symbol
moveTo: direction
toString: () -> [this.nextState, this.writeSymbol, this.moveTo].join ", "
createRule = (state, symbol, result) ->
inState: state
@lcbasu
lcbasu / turing.coffee
Created November 28, 2012 07:01 — forked from jamesrcounts/turing.coffee
A turing machine in coffeescript
alert = (s) -> console.log s
createResult = (state, symbol, direction) ->
nextState: state
writeSymbol: symbol
moveTo: direction
toString: () -> [this.nextState, this.writeSymbol, this.moveTo].join ", "
createRule = (state, symbol, result) ->
inState: state