Skip to content

Instantly share code, notes, and snippets.

View adamblank's full-sized avatar

Adam Blank adamblank

  • California, US
View GitHub Profile
@adamblank
adamblank / git-config.sh
Last active May 7, 2021 21:25
Git Aliases
# A place for my git aliases
git config --global alias.lop 'log --pretty=oneline'
git config --global alias.pur 'pull --rebase'
git config --global alias.s 'status'
git config --global alias.c 'commit'
git config --global alias.cm 'commit -m'
git config --global alias.cam 'commit -a -m'
git config --global alias.fix 'commit --amend'
git config --global alias.fixup 'commit --fixup :/'
@adamblank
adamblank / fake_progress_bar_width.js
Created November 24, 2015 16:48
This little utility changes the "width" (i.e. of a progress bar) with sense of unpredictability. The obj implementation is just to make it generic-ish (was originally a React component method.) The only logic that's been tested is marked below as "the meat"
const obj = {
width: 0,
start() {
let extra = 0;
let interval = setInterval(() => {
if (width === 100) {
clearInterval(interval);
}
// the meat
if (Math.floor(Math.random() + 0.6)) {
import java.util.*;
public class MyApp {
protected List<Integer[]> meetings = new ArrayList<>();
public MyApp() {
meetings.add(new Integer[] { 3, 5});
meetings.add(new Integer[] { 0, 1});
meetings.add(new Integer[] { 4, 8});
public class Node {
protected String data;
protected Node next;
public Node(final String data, final Node next) {
this.data = data;
this.next = next;
}
public Node getNext() {
var arr = [1, 7, 3, 4];
var brute = function(arr) {
var i = 0;
var final_arr = [];
var temp_arr;
var j;
for (i; i < arr.length; i++) {
temp_arr = arr.slice();
temp_arr.splice(i, 1);
var stock_prices = [15,14,11,10,8,6,5,2,1];//[10,11,12,15,8,9,10,14,11];//[10, 9, 8, 10, 13, 11, 9, 10, 15];
var max_and_min = [];
var i = stock_prices.length - 1;
for (i; i >= 0; i--) {
if (max_and_min.length && (max_and_min[0].min == null || max_and_min[0].min > stock_prices[i])) {
max_and_min[0].min = stock_prices[i];
}
if (!max_and_min.length || max_and_min[0].max < stock_prices[i]) {
/*
* Boilerplate thread local singleton
*/
protected Singleton() {} //enforce singleton pattern with protected constructor
private static ThreadLocal<Singleton> instance = null; //the current thread instance
/** Get the singleton instance of this service
* If no instance exists for this thread, instantiate one
*
@adamblank
adamblank / jsonToTable.js
Created January 26, 2014 19:35
Generate generic HTML table from JSON
function generateTable(arr) {
var content = {},
headers = [],
longest = 0;
function setEmpies(content) {
for (var key in content) {
if (!content[key].affected) {
content[key].push('');
@adamblank
adamblank / webkit.scrollbar.css
Created December 10, 2013 19:36
webkit styled minimalist gray scrollbar
::-webkit-scrollbar{
width: 10px;
}
::-webkit-scrollbar-track-piece{
background-color: #FFF;
}
::-webkit-scrollbar-thumb{
background-color: #CBCBCB;
@adamblank
adamblank / underscore.compile.js
Last active December 30, 2015 19:39
Add a compile method to underscore, to accommodate for typeahead's expected API
_.compile = function(templ) {
var compiled = this.template(templ);
compiled.render = function(ctx) {
return this(ctx);
};
return compiled;
}