Skip to content

Instantly share code, notes, and snippets.

View stephancom's full-sized avatar

stephan.com stephancom

View GitHub Profile
@Threeethan
Threeethan / gist:8772775
Created February 2, 2014 18:37
BlinkyTape Interrupt Example
#include <FastSPI_LED2.h>
#define DEBUG
#define LED_COUNT 60 // BlinkyTape has 60 LEDs!
struct CRGB leds[LED_COUNT]; // this struct contains 60 CRGB values. This is where
#define LED_MAX_BRIGHTNESS 55
#define PIN_BUTTON 10
@JamesHagerman
JamesHagerman / gist:3662fa257366f5f4345f
Last active August 29, 2015 14:17
RedCloth + Monkey Patch = Prism working
# RedCloth doesn't work well with the Prism syntax highlighting lirbary due to the way it handles <code> blocks when it comes to newlines using bc..
# But we can add a config/initializers/redcloth.yml file to our Rails app and monkey patch it so it does.
#
# So, this monkey patch is to make RedCloth not split the bc.. code blocks on newlines.
# To actually use it with Prism the syntax should look like this:
# bc(language-ruby).. whatever multi-line code you want to display goes here
module RedCloth::Formatters::HTML
def bc_open(opts)
opts[:block] = true
"<pre#{pba(opts)}><code>"
class ApplicationController < ActionController::Base
before_filter :delay_xhr
protected
def delay_xhr
session[:delay_ajax] = params[:delay_ajax].to_i unless params[:delay_ajax].blank?
sleep session[:delay_ajax] if !session[:delay_ajax].nil? && session[:delay_ajax] > 0 && request.xhr?
end
<input
ng-model="searchPhrase"
ng-model-options="{debounce: 500}"
ng-change="getResults(searchPhrase)"></input>
@niels
niels / Gemfile
Created April 5, 2013 14:07
Working Rails 4 w/ Compass
source "https://rubygems.org"
gem "devise", git: "git://github.com/plataformatec/devise.git", branch: "rails4"
gem "devise-i18n", "~> 0.6.5"
gem "jbuilder", "~> 1.0.1"
gem "jquery-rails"
gem "haml", "~> 4.0.1"
gem "mongoid", git: "git://github.com/mongoid/mongoid.git", branch: "master"
gem "simple_form", "~> 3.0.0.beta1"
gem "rails", "4.0.0.beta1"
module TableHelpers
module ArrayMethods
def find_row(expected_row)
find_index do |row|
expected_row.all? do |expected_column|
first_column = row.find_index do |column|
content = normalize_content(column.content)
expected_content = normalize_content(expected_column)
matching_parts = expected_content.split(/\s*\*\s*/, -1).collect { |part| Regexp.escape(part) }
@dolzenko
dolzenko / sidekiq_paper_trail_middleware.rb
Created December 18, 2014 13:01
Make originator of change tracked with paper_trail available in Sidekiq background workers
module Acme
module Sidekiq
module PaperTrailMiddleware
class Client
# @param [Object]
# @param [Hash] job
def call(_, job, *)
job['whodunnit'] = ::PaperTrail.whodunnit
yield
end
@mikestone14
mikestone14 / gist:11198630
Created April 23, 2014 00:08
Getting a GoDaddy domain to point to a Heroku app.
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/npm-* && rm -rf $TMPDIR/haste-* && rm -rf $TMPDIR/metro-* && rm -rf node_modules && npm install && rm -rf ios/Pods && cd ios && pod cache clean --all && pod repo update && pod install && ./android/gradlew clean -p ./android/ && rm -rf ios/build && rm -rf ~/Library/Developer/Xcode/DerivedData && npm start -- --reset-cache
@bobchao
bobchao / m_test.txt
Created December 22, 2017 14:08
cubiio - g-code file for power / speed combinations testing.
M05 S0
G90
G21
G1 F600
G1 X-40.225 Y39.6688
G4 P0
M03 S255
G4 P0
G1 F600.000000