Skip to content

Instantly share code, notes, and snippets.

View tokenvolt's full-sized avatar

Alex Khrustalev tokenvolt

View GitHub Profile
@staltz
staltz / introrx.md
Last active April 19, 2025 05:15
The introduction to Reactive Programming you've been missing
@chrismccoy
chrismccoy / gitcheats.txt
Last active February 27, 2025 15:51
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"
# aliases to change a git repo from private to public, and public to private using gh-cli
alias gitpublic="gh repo edit --accept-visibility-change-consequences --visibility public"
alias gitprivate="gh repo edit --accept-visibility-change-consequences --visibility private"
# delete all your repos using gh-cli (please do not run this unless you want to delete all your repos)
gh repo list --limit 300 --json url -q '.[].url' | xargs -n1 gh repo delete --yes
@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;
@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"
@michaelminter
michaelminter / scp.md
Created November 8, 2013 21:11
scp examples # command line, linux, mac

#Example syntax for Secure Copy (scp)

##What is Secure Copy?

scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

###Examples

Copy the file "foobar.txt" from a remote host to the local host

@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
if Rails.env == "production" || Rails.env == "staging"
exceptions = []
exceptions << 'ActiveRecord::RecordNotFound'
exceptions << 'AbstractController::ActionNotFound'
exceptions << 'ActionController::RoutingError'
exceptions << 'ActionController::InvalidAuthenticityToken'
server_name = case Rails.env
when "production" then "mystore.com"
@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@soeffing
soeffing / Gruntfile.js
Created September 4, 2013 09:30
Example of a Gruntfile.js configuration if you plan to develop with AngularJS and an Rails JSON API
// Generated on 2013-08-13 using generator-angular 0.3.1
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({ port: LIVERELOAD_PORT });
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
// # Globbing

PageObject + SimpleDelegator = Awesome Capybara Helpers

I've always liked using the Page Object pattern to write concise, namespaced, and composeable capybara helpers:

When /^I register as a new user$/ do
  NewUserPage.new(self).tap do |page|
    page.visit!
    page.form.fill

page.form.submit!