Skip to content

Instantly share code, notes, and snippets.

View tokenvolt's full-sized avatar

Alex Khrustalev tokenvolt

View GitHub Profile
@tcnksm
tcnksm / exception_spec.rb
Created November 12, 2013 08:20
How to stub raising exceptions in rspec
class Foo
class << self
def exec
something
rescue => ex
ex.message
end
def something
"something"
@ericflo
ericflo / reactdropzone.js
Last active September 15, 2016 09:00
ReactDropzone, a react component for interfacing with http://www.dropzonejs.com/
/** @jsx React.DOM */
var ReactDropzone = React.createClass({
componentDidMount: function() {
var options = {};
for (var opt in Dropzone.prototype.defaultOptions) {
var prop = this.props[opt];
if (prop) {
options[opt] = prop;
continue;
@chrismccoy
chrismccoy / gitcheats.txt
Last active April 7, 2026 13:35
git cheats
# alias to edit commit messages without using rebase interactive
# example: git reword commithash message
reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f"
# git alias to download single file from a repo in format of user/repo file
fetch-file = "!f() { out=\"${4:-$(basename \"$2\")}\"; if gh api \"repos/$1/contents/$2\" ${3:+-f ref=$3} --jq '.content' 2>/dev/null | base64 --decode > \"$out\" 2>/dev/null; then echo \"Downloaded $2 → $out\"; else echo \"Failed\"; rm -f \"$out\"; fi; }; f"
# git alias to download single file from a repo in the format of user/repo/file
fetch-file = "!f() { repo=\"$(echo $1 | cut -d/ -f1-2)\"; file=\"$(echo $1 | cut -d/ -f3-)\"; out=\"${3:-$(basename \"$file\")}\"; if gh api \"repos/$repo/contents/$file\" ${2:+-f ref=$2} --jq '.content' 2>/dev/null | base64 --decode > \"$out\" 2>/dev/null; then echo \"Downloaded $file → $out\"; else echo \"Failed\"; rm -f \"$out\"; fi;
@staltz
staltz / introrx.md
Last active April 14, 2026 03:11
The introduction to Reactive Programming you've been missing
@john2x
john2x / 00_destructuring.md
Last active March 14, 2026 08:35
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@nrn
nrn / react-internals.md
Last active April 1, 2018 18:02
Notes for react internals discussion.

react internals discussion

React: a robust functional view layer.

View code and templating are combined as JavaScript.

In JavaScript you create a virtual DOM, react diffs changes between the last virtual DOM and the next, mutating the real DOM only as necessary to reflect the changes. This has huge implications for cognitive

@gaearon
gaearon / AudioPlayer.jsx
Created October 31, 2014 22:13
React <audio> wrapper
/** @jsx React.DOM */
'use strict';
var React = require('react'),
{ PropTypes } = React;
var AudioPlayer = React.createClass({
propTypes: {
source: PropTypes.string.isRequired,
isPlaying: PropTypes.bool.isRequired,
@paf31
paf31 / 24days.md
Last active August 8, 2023 05:53
24 Days of PureScript

This blog post series has moved here.

You might also be interested in the 2016 version.

@koistya
koistya / React-Directory-Layout.md
Last active July 30, 2025 05:53
File and folder naming convention for React.js components

File and folder naming convention for React.js components

Directory Layout #1

/actions/...
/components/common/Link.js
/components/common/...
/components/forms/TextBox.js
/components/forms/TextBox.res/style.css
.
├── actions
├── stores
├── views
│   ├── Anonymous
│   │   ├── __tests__
│   │   ├── views
│   │   │   ├── Home
│   │   │   │   ├── __tests__
│   │   │   │   └── Handler.js