Skip to content

Instantly share code, notes, and snippets.

View machuga's full-sized avatar

Matt Machuga machuga

View GitHub Profile
@machuga
machuga / callback-purgatory-0.js
Last active March 22, 2019 21:07
Grokkable Concurrent JavaScript - Teaching Asynchronous Patterns and Refactorings
const get = require('./get'); // get(url, callback)
const githubApi = 'https://api.github.com';
const githubEventsUrlFor = username => `${githubApi}/users/${username}/events`;
const githubRepoUrlFor = repo => `${githubApi}/repos/${repo}`;
const fetchReposForLatestActivity = (user, callback) => {
let timeout = setTimeout(function() {
callback(new Error('Timed out'));
}, 3000);
@machuga
machuga / google_analytics_turbolinks5.js
Created May 12, 2017 10:59 — forked from Startouf/ google_analytics_turbolinks5.js
Google Analytics for Turbolinks 5 (& Rails 5)
// Google Analytics code to work with Turbolniks 5
this.GoogleAnalytics = (function() {
function GoogleAnalytics() {}
GoogleAnalytics.load = function() {
var firstScript, ga;
window._gaq = [];
window._gaq.push(["_setAccount", GoogleAnalytics.analyticsId()]);
window._gaq.push(['_setAllowAnchor', true]);
@machuga
machuga / promise-example.js
Created November 18, 2016 00:03
Promise Example for Promise Talk
const githubApi = 'https://api.github.com';
const githubEventUrl = githubApi + '/users/machuga/events';
fetchReposForLatestActivity('machuga').then(console.log);
function fetchReposForLatestActivity(user, fn) {
return new Promise(function(resolve, reject) {
request(githubEventsUrlFor(user))
.then(getThreeEvents)
.then(fetchRepos)
@machuga
machuga / callback-example.js
Last active November 18, 2016 02:25
Callback Example for Promise Talk
const githubApi = 'https://api.github.com';
const githubEventUrl = githubApi + '/users/machuga/events';
fetchReposForLatestActivity('machuga', console.log);
function fetchReposForLatestActivity(user, fn) {
request(githubEventsUrlFor(user), function(allEvents) {
fetchRepos(getThreeEvents(allEvents), function(rawRepos) {
fn(rawRepos.map(getRepo));
});
@machuga
machuga / index.js
Last active January 9, 2016 20:51
Express Elm Compilation - basic functionality example. Needs refinement
'use strict';
const spawn = require('child_process').spawn;
const express = require('express');
const app = express();
const server = require('http').createServer(app);
const compile = require("node-elm-compiler").compile;
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
@machuga
machuga / evil-leader.el
Created October 6, 2015 17:52
Evil Leader config
(global-evil-leader-mode)
(evil-leader/set-leader "<SPC>")
(evil-leader/set-key
"j" 'evil-window-down
"k" 'evil-window-up
"h" 'evil-window-left
"l" 'evil-window-right
"J" 'evil-window-move-very-bottom
"K" 'evil-window-move-very-top
#include <unistd.h>
#include <mach/mach.h>
#include <mach/mach_vm.h>
#include <mach-o/dyld.h>
int
main (int argc, char * argv[])
{
volatile char * library;
const mach_vm_size_t page_size = getpagesize ();
@machuga
machuga / rules.md
Last active September 22, 2023 19:45 — forked from radar/rules.md
#laravel rules

Asking for help in #laravel on Freenode

Please behave in a polite, considerate, and inclusive manner in the channel at all times. People volunteer their time in the channel to help people like you with your Laravel problems and some respect (in both directions) will go an extremely long way.

When asking questions in the #laravel channel, please follow these 12 simple rules.

  1. Do your research before hand. Your question may be answerable with a quick Google search or by simply experimenting. If it's a concept you're confused about, first check out our Official Documentation. If you're using a method in Laravel, you can look it up in the API Docs.
  2. If you've tried Googling, explain what terms you've tried to use so people can better help you.
  3. Clearly explain what is happening and create a Paste (http://laravel.io/bin), (http://kopy.io), or (http://gist.github.com) to better explain yourself
  4. **Do not use any paste service that is no
@machuga
machuga / Gemfile
Last active December 14, 2015 17:29
Guard for Jasmine CLI tests
source :rubygems
gem 'guard'
gem 'guard-shell'
gem 'rb-fsevent', :require => false
gem 'terminal-notifier-guard' # This will use OSX native notifications
@machuga
machuga / .vimrc
Created July 13, 2012 11:04
Vimrc file 07-13-2012
set nocompatible
set number
set ruler
syntax on
" Set encoding
set encoding=utf-8
" Whitespace stuff