git status
git diff // diff working_dir vs last_commit
git log
git log --graph // visualize graph topology in terminal
gitk // visualize graph topology in gitk (GUI)
git add . // stage new & modified files, without deleted
git add -u // stage modified & deleted files, without new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === Program | |
class Main | |
def compare(n1, n2) | |
(n1 + n2).to_i > (n2 + n1).to_i | |
end | |
def special_sort(arr) | |
result = [] | |
temp = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === Program v1 [time complexity: O(n^2)] | |
class Main | |
def equilibrium_index(arr) | |
result = [] | |
arr.each_with_index do |el, i| | |
j = 0 | |
sum_prefix = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# === [Lesson 2: Arrays] - CyclicRotation | |
# === Program v1 (recursive) | |
def solution(a, k) | |
return a if k == 0 || a.length == 0 | |
a = a.unshift(a.delete_at(a.length - 1)) | |
k -= 1 | |
return solution(a, k) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# custom bash, copied from Vagabond box | |
bind 'set completion-ignore-case on' | |
GIT_PS1_SHOWDIRTYSTATE=1 # displays * or + | |
GIT_PS1_SHOWSTASHSTATE=1 # displays $ | |
GIT_PS1_SHOWUNTRACKEDFILES=1 # displays % | |
GIT_PS1_SHOWUPSTREAM='auto' # displays <, >, <> or = | |
GIT_PS1_SHOWCOLORHINTS=1 | |
GIT_PS1_DESCRIBE_STYLE='contains' | |
RESET="\[\033[0m\]" | |
GRAY="\[\033[38;5;248m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. | |
contains an array of paths that your script will search through when using require. | |
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name. | |
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script. | |
$? (Dollar Question Mark) returns the exit status of the last child process to finish. | |
$$ (Dollar Dollar) returns the process number of the program currently being ran. | |
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match. | |
$1, $2, $3, $4 etc represent the content of the previous successful pattern match. | |
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match. | |
$+ (Dollar Plus) contains the last match from the previous successful pattern match. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/localtunnel/localtunnel/issues/81#issuecomment-218320442 | |
# usage: ruby localtunnel.rb --port 3000 --subdomain yourdomainhere | |
require 'optparse' | |
options = { subdomain: 'defaultdomain', port: 3000 } | |
parser = OptionParser.new do |opts| | |
opts.banner = 'Usage: localtunnel.rb [options]' | |
opts.on('-s', '--subdomain subdomain', 'Subdomain') do |subdomain| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Adapted from: | |
-- https://gist.github.com/eric-hu/5846890 | |
-- | |
-- Modified to work with files as well, cd-ing to their container folder | |
on run {input, parameters} | |
tell application "Finder" | |
set my_file to first item of input | |
set filetype to (kind of (info for my_file)) | |
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer: | |
-- http://stackoverflow.com/a/6881524/640517 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var app = express() | |
var request = require('request') | |
app.use(require('body-parser').json()) | |
var endpoints = require('./endpoints.json') | |
var response = require('./response.json') | |
app.all("*", function(req, res) { | |
endpoints.forEach(function(ept) { | |
full_url = ept + req.url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [A] OpenSSL::PKey::RSA has undocumented `e=' and `n=' methods | |
exponent = "10001" | |
modulus = "9201EBD5DC974FDE613A85AFF2728627FD2C227F18CF1C864FBBA3781908BB7BD72C818FC37D0B70EF8708705C623DF4A9427A051B3C8205631716AAAC3FCB76114D91036E0CAEFA454254D135A1A197C1706A55171D26A2CC3E9371B86A725458E82AB82C848AB03F4F0AF3127E7B2857C3B131D52B02F9A408F4635DA7121B5B4A53CEDE687D213F696D3116EB682A4CEFE6EDFC54D25B7C57D345F990BB5D8D0C92033639FAC27AD232D9D474896668572F494065BC7747FF4B809FE3084A5E947F72E59309EDEAA5F2D81027429BF4827FB62006F763AFB2153C4A959E579390679FFD7ADE1DFE627955628DC6F2669A321626D699A094FFF98243A7C105" | |
rsa = OpenSSL::PKey::RSA.new | |
e = exponent.to_i(16) | |
n = modulus.to_i(16) | |
rsa.e = OpenSSL::BN.new(e) | |
rsa.n = OpenSSL::BN.new(n) |
OlderNewer