Skip to content

Instantly share code, notes, and snippets.

View galacticmonkeys's full-sized avatar

Yuan Yuan galacticmonkeys

View GitHub Profile
@galacticmonkeys
galacticmonkeys / combo.js
Created April 10, 2016 07:05
If a=1, b=2, c=3,....z=26. Given a string, find all possible codes that string can generate. Give a count as well as print the strings. For example: Input: "1123". You need to general all valid alphabet codes from this string.
// js implementation
function combination(stringOfNum) {
if (stringOfNum.length == 1) {
return 1;
} else {
var res = [];
res[0] = 1;
for (var n = 1; n < stringOfNum.length; n++) {
var condition = (parseInt(stringOfNum.slice(-2)) <= 26) ? 1 : 0;
@galacticmonkeys
galacticmonkeys / combo.js
Created April 10, 2016 07:05
If a=1, b=2, c=3,....z=26. Given a string, find all possible codes that string can generate. Give a count as well as print the strings. For example: Input: "1123". You need to general all valid alphabet codes from this string.
// js implementation
function combination(stringOfNum) {
if (stringOfNum.length == 1) {
return 1;
} else {
var res = [];
res[0] = 1;
for (var n = 1; n < stringOfNum.length; n++) {
var condition = (parseInt(stringOfNum.slice(-2)) <= 26) ? 1 : 0;
@galacticmonkeys
galacticmonkeys / combo.js
Created April 10, 2016 07:05
If a=1, b=2, c=3,....z=26. Given a string, find all possible codes that string can generate. Give a count as well as print the strings. For example: Input: "1123". You need to general all valid alphabet codes from this string.
// dp practice
// js implementation
function combination(stringOfNum) {
if (stringOfNum.length == 1) {
return 1;
} else {
var res = [];
res[0] = 1;
for (var n = 1; n < stringOfNum.length; n++) {
@galacticmonkeys
galacticmonkeys / rememberssh.md
Last active March 2, 2016 19:26
How To scp, ssh and rsync without prompting for password

##How To scp, ssh and rsync without prompting for password ######By jkini on Oct 17, 2007 ######Edited by Yuan Yuan on Feb 29, 2016

host_src = you, host_dest = remote

  1. On host_src: If you've previously generated SSH keys before, $ ssh-keygen shows where it saved the public key. This is by default ~/.ssh/id_rsa.pub If you've never generate a SSH key before, do so by running this command: $ ssh-keygen -t rsa.
This will prompt for a passphrase. Just press the enter key. It'll then generate an identification (private key) and a public key. Do not ever share the private key with anyone!

  2. Transfer the id_rsa.pub file to host_dest by either ftp, scp, rsync or any other method (see http://www.hypexr.org/linux_scp_help.php)

@galacticmonkeys
galacticmonkeys / JSinheritance.txt
Last active February 28, 2016 22:30
JavaScript Prototypal Inheritance
Children only look up the prototype chain when:
- reading a property that does not currently exist in the child scope
Children do not look up the chain when:
- setting a child scope property
- reading a child scope property that already exists in the child scope.
Now, if you happen to set a property before reading it, the child will, of course, get its own scope.
Example:
@galacticmonkeys
galacticmonkeys / filemaker.sh
Created February 25, 2016 23:43
Make a new file for each item in list
for file in asdf qwer zxcv
do
touch "$file"
done
@galacticmonkeys
galacticmonkeys / form.html
Last active October 19, 2015 23:10
BJC file uploader
<h1>BJC File Uploader</h1>
<form id="myForm">
<input id="name" type="text" name="myName" placeholder="Your name (required)">
<input id="file" type="file" name="myFile" onchange="document.getElementById('file').classList.add('uploaded');">
<textarea name="comments" rows="3" cols="40" placeholder="Additional comments (optional)"></textarea>
<input type="submit" value="Upload File" onclick="processFile()">
</form>
<div id="upload-complete">
Your file has uploaded successfully.
" pathogen plugin
execute pathogen#infect()
" vim things
syntax on
filetype plugin indent on
set autoindent
set smartindent
set tabstop=2
set softtabstop=2
echo "word to replace"
read variable
LANG=C LANG_ALL=C find js/app -type f -exec sed -i '' "s/chrome\.extension\.$variable/chrome\.runtime\.$variable/g" {} +
@galacticmonkeys
galacticmonkeys / sync.sh
Created July 6, 2015 20:56
syncs the master branch with gh-pages
git checkout gh-pages
git merge master
git push origin gh-pages
git checkout master