Skip to content

Instantly share code, notes, and snippets.

/**
*
* Print From 45 to 4578 Without Repeating Digits
*
* Write a method that prints all the numbers from 45 to 4578 to the console,
* with the constraint that you cannot print any number with repeating digits.
* This means the following numbers would be skipped: 11, 22, ...., 122, 110,....
*
* Created by vbauer on 19/04/14.
*/
var bsearch = function(arr, k){
var l = 0, r = arr.length-1, m;
console.log(arr);
while(l<r){
m = (l+r)/2^0;
console.log(m);
if(k>arr[m])
@vbauerster
vbauerster / Random.nextInt
Created May 5, 2014 19:58
java.util.Random.nextInt(n)
public int nextInt(int n) {
if (n <= 0)
throw new IllegalArgumentException("n must be positive");
if ((n & -n) == n) // i.e., n is a power of 2
return (int)((n * (long)next(31)) >> 31);
int bits, val;
do {
bits = next(31);
@vbauerster
vbauerster / change_prompt.txt
Created May 11, 2014 08:35
terminal prompt modifications
PS1='\[\e]1;My Desk\a\e]2;${PWD}\a\]\
[\u@ME \w]\n \#\$ '
PS1='\[\e]2;${PWD}\a\
\e[0;34m\]\
[\u@MyMacBook \w]\n \#\$ \
\[\e[m\]'
#Default, but Working Dir in blue color
PS1='\h:\[\e[0;34m\]\W \[\e[m\]\u\$ '
@vbauerster
vbauerster / gist:78d48f1c3fa9f430e018
Last active April 8, 2018 02:27 — forked from jordelver/gist:3073101
Set the Mac OS X SOCKS proxy on the command line

Set the Mac OS X SOCKS proxy on the command line

a.k.a. what to do when your ISP starts blocking sites :(

Set the SOCKS proxy to local SSH tunnel

networksetup -setsocksfirewallproxy "Ethernet" localhost 8080

To clear the domain and port

function* objectEntries(obj) {
let propKeys = Reflect.ownKeys(obj);
for (let propKey of propKeys) {
yield [propKey, obj[propKey]];
}
}
let jane = { first: 'Jane', last: 'Doe' };
for (let [key, value] of objectEntries(jane)) {
cd `brew --prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew
forever start -e ~/.npm-local/err.log --plain --workingDir ~/.npm-local /usr/local/bin/local-npm
sudo easy_install pip
pip install --user neovim
define(function(require){
//var React = require('react');
var jQuery = require('jquery');
//var TemplatesPanel = require('modules/pathboard/common/views/templatesPanel');
//var Templates = require('modules/pathboard/common/models/templates');
//var templates = new Templates();
//var Loading = require('ui/react/loading');
//var Panel = require('ui/react/modals/panel');