Skip to content

Instantly share code, notes, and snippets.

View mtvillwock's full-sized avatar

Matthew Villwock mtvillwock

View GitHub Profile
@crizstian
crizstian / solid.js
Last active January 12, 2025 07:50
Code examples of SOLID principles for JavaScript
/*
Code examples from the article: S.O.L.I.D The first 5 priciples of Object Oriented Design with JavaScript
https://medium.com/@cramirez92/s-o-l-i-d-the-first-5-priciples-of-object-oriented-design-with-javascript-790f6ac9b9fa#.7uj4n7rsa
*/
const shapeInterface = (state) => ({
type: 'shapeInterface',
area: () => state.area(state)
})
@zeuxisoo
zeuxisoo / guess-number.go
Last active September 25, 2019 21:42
A simple program ask user to guess the number
package main
import (
"os"
"fmt"
"bufio"
"strings"
"strconv"
"time"
"math/rand"
@ashfurrow
ashfurrow / Fresh macOS Setup.md
Last active October 14, 2024 10:28
All the stuff I do on a fresh macOS Installation

Apps to install from macOS App Store:

  • Pastebot
  • GIF Brewery
  • Slack
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 3
  • Airmail 3
  • iA Writer
@oelmekki
oelmekki / doc.md
Created December 30, 2015 19:37
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

@bluenex
bluenex / zsh_envi.md
Last active May 17, 2023 19:31
Moving to Zsh note and configuration settings.

Moving to Zsh

Have a good time with bash for a long while, it's time to try another tempting shell - Zsh. So, this Gist is nothing but my collection for the environment that I've searched and applied to my system. There is also this kind of Gist in a version of bash.

Why Zsh?

There are several shells out there but this is the one that is close to the bash with some useful and attractive features especially - yes, theme. Here are some good articles about how and why to choose Zsh over bash, enjoy trying!

@tenderlove
tenderlove / h2_puma.rb
Last active August 14, 2024 06:10
Demo HTTP/2 server with Puma
require 'socket'
require 'openssl'
require 'puma/server'
require 'ds9'
class Server < DS9::Server
def initialize socket, app
@app = app
@read_streams = {}
@write_streams = {}
var results = [];
var app = {
initialize: function() {
var arr = [
this.generateMediaObj('imgs/avengers.jpg', "Avengers", "2012"),
this.generateMediaObj('imgs/blade_runner.jpg', "Blade Runner", "1982")
];
/* eachLimit(arr, limit, iterator, callback) */
async.eachLimit(arr, 1, this.makeRequest, this.onComplete);
@zeuxisoo
zeuxisoo / package.json
Created April 28, 2015 12:49
Simple script for fetch and save the word definition to local html file in console
{
"dependencies": {
"async": "^0.9.0",
"cheerio": "^0.19.0",
"datauri": "^0.6.0",
"unirest": "^0.4.0"
}
}
@adamsanderson
adamsanderson / README.markdown
Created March 29, 2015 23:42
Hash vs Array vs Set

For simple duplicate checking, which is faster, a Ruby hash, array, or set?

For arrays, we try two approaches, when inserting data either avoid duplicates, or just add them to the list.

This is most likely flawed, and should probably be taken with a grain of salt.

@irazasyed
irazasyed / manage-etc-hosts.sh
Created March 7, 2015 09:16
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1