Skip to content

Instantly share code, notes, and snippets.

@justmoon
justmoon / custom-error.js
Last active April 22, 2024 17:19 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
@sjl
sjl / ext.vim
Created December 15, 2014 18:58
ways to run external commands in vim
" run command
" no stdin
" output displayed in "Press enter to continue" style
" current buffer untouched
:!uptime
" run command
" pipe range of text to command on stdin
" output replaces the range in the current buffer
:RANGE!grep foo
@ludyna
ludyna / dci_example.rb
Last active March 20, 2018 20:08
DCI (Data, Contexts, Interactions) paradigm example in Ruby
# DCI EXAMPLE IN RUBY (with some prototype elements)
# Blog post: https://www.ludyna.com/oleh/dci-example-in-ruby
#
# More info:
#
# Creator of MVC & DCI, Trygve Reenskaug: DCI: Re-thinking the foundations of
# object orientation and of programming
# http://vimeo.com/8235394
#
# James Coplien: Why DCI is the Right Architecture for Right Now
# swith to sudo
sudo -i
# create swap
touch /2GiB.swap
chattr +C /2GiB.swap
fallocate -l 2048m /2GiB.swap
chmod 600 /2GiB.swap
mkswap /2GiB.swap
@netpoetica
netpoetica / Compiling v8 and Hello, World Example on Mac OSX Mavericks (10.9.4).md
Last active August 7, 2022 09:25
Compiling v8 and Hello, World Example on Mac OSX Mavericks (10.9.4), Link Clang to Static Libraries, properly configure your environment for v8 build

Compiling v8 and Hello, World Example on Mac OSX Mavericks (10.9.4)

by Keith Rosenberg (netpoetica)

Note: do this in some sort of project/ directory that makes sense. depot_tools are going to need to be in your path, so you may want to install them somewhere you are comfortable with.

1) Get the v8 source

git clone https://github.com/v8/v8.git

2) Install depot tools

@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@runlevel5
runlevel5 / lotus_console.md
Last active August 29, 2015 14:02
A simple rake task that replicates the `rails console` for Lotus Framework

Lotus Console

A simple rake task that replicates the rails console for Lotus Framework

How to?

I assume that your config/application.rb is the place where you initialize all Lotus boot config

below is my config/application.rb for your interest

@afn
afn / gist:c04ccfe71d648763b306
Created June 12, 2014 15:35
Restart phantomjs when it hangs
# Borrowed from https://github.com/y310/rspec-retry/blob/master/lib/rspec/retry.rb
CAPYBARA_TIMEOUT_RETRIES = 3
RSpec.configure do |config|
config.around(:each, type: :feature) do |ex|
example = RSpec.current_example
CAPYBARA_TIMEOUT_RETRIES.times do |i|
example.instance_variable_set('@exception', nil)
self.instance_variable_set('@__memoized', nil) # clear let variables
@jaimalchohan
jaimalchohan / github.rb
Last active January 1, 2016 04:19 — forked from plusjade/github.rb
Updated for breaking changes in ruhoh 2.6
require 'tmpdir'
# Usage:
# add to ruhoh-site/plugins/publish/github.rb
# - Your GitHub remote must be setup properly but The command will try to walk you through it.
# - You must have a clean working directory to publish to GitHub pages since the hook is actually triggered by commits.
#
# $ cd ruhoh-site
# $ bundle exec ruhoh publish github
class Ruhoh
@jvns
jvns / executing-file.md
Last active August 5, 2023 22:24
What happens when I run ./hello