Skip to content

Instantly share code, notes, and snippets.

@deanrad
deanrad / cors.js
Last active April 9, 2021 09:26
Using CORS-Anywhere via AJAX
/*
If you are attempting to call an AJAX API, via GET which responds:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
You can modify the way you query it to go through a server which will add the header.
Basically, you add the URL you want (with query string parameters) at the end of
'https://cors-anywhere.herokuapp.com/'
, and ensure that your ajax call is done with some additional options as shown below
See CORS-Anywhere documentation here for more:
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@micmarsh
micmarsh / dopromise.coffee
Last active August 29, 2015 14:01
Haskell Do Notation for JavaScript Promises
COMPILED_COFFEE = ' < -'
PLAIN_JS = '<-'
thenify = (lines) ->
[line, rest...] = lines
if rest.length is 0
line
else if line.search(PLAIN_JS) > 0 or line.search(COMPILED_COFFEE) > 0
[value, promise] = line.split if line.search(PLAIN_JS) > 0 then PLAIN_JS else COMPILED_COFFEE
noSemiColon = promise.slice(0, -1)
@nickloewen
nickloewen / bret_victor-reading_list.md
Last active March 7, 2024 18:14
Bret Victor’s Reading List

This is a plain-text version of Bret Victor’s reading list. It was requested by hf on Hacker News.


Highly recommended things!

This is my five-star list. These are my favorite things in all the world.

A few of these works have had an extraordinary effect on my life or way of thinking. They get a sixth star. ★

@brandly
brandly / branch.md
Last active January 3, 2016 12:19
thoughts on branching and pull requests

here's how i think of branching.

purpose of branching

you need to write some code. since you may end up writing good code, but there's a chance you'll write bad code, branches allow you to freely commit your changes as you go along without affecting the core of the project. if you end up with something you don't like, you can clip the branch like nothing ever happened.

i think branches fall into a few categories.

bugs

def shannon_entropy(img):
# calculate the shannon entropy for an image
histogram = img.histogram()
histogram_length = sum(histogram)
samples_probability = [float(h) / histogram_length for h in histogram]
return -sum([p * math.log(p, 2) for p in samples_probability if p != 0])
@adamgit
adamgit / .gitignore
Last active April 8, 2024 12:58
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@vitaLee
vitaLee / snap_lines_to_indent_level_command.py
Created June 5, 2012 17:02
SublimeText command for snapping displaced text to indentation
# sample shortcuts
{ "keys": ["ctrl+super+]"], "command": "snap_lines_to_indent_level", "args": { "snap_direction": 1 } },
{ "keys": ["ctrl+super+["], "command": "snap_lines_to_indent_level", "args": { "snap_direction": -1 } }
@rakhmad
rakhmad / clojure.md
Created April 17, 2012 15:55
Setting Up Clojure on OS X

Setting Up Clojure on OS X

I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.

I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.

This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.

Step 1: Getting Clojure (1.3)

@artero
artero / launch_sublime_from_terminal.markdown
Last active January 25, 2024 16:57 — forked from olivierlacan/launch_sublime_from_terminal.markdown
Launch Sublime Text 2 from the Mac OS X Terminal

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation