This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Outputs this at warn log level: | |
| # 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]} | |
| # | |
| # Save as config/initializers/oneline_detailed_logging.rb. Consider | |
| # decreasing the log level from "info" to "warn" (in production.rb) so | |
| # the one-line log message replaces the standard request logs. | |
| # override process_action to add 2 things to the payload: | |
| # - remote IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Written by Limor "Ladyada" Fried for Adafruit Industries, (c) 2015 | |
| # This code is released into the public domain | |
| import time | |
| import os | |
| import RPi.GPIO as GPIO | |
| GPIO.setmode(GPIO.BCM) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/a/10031877 | |
| import numpy | |
| import cairo | |
| import math | |
| from gi.repository import Gtk,Gdk | |
| data = numpy.zeros((200, 200, 4), dtype=numpy.uint8) | |
| surface = cairo.ImageSurface.create_for_data( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .factory('TokenHandler', function() { | |
| var tokenHandler = {}; | |
| var token = "none"; | |
| tokenHandler.set = function( newToken ) { | |
| token = newToken; | |
| }; | |
| tokenHandler.get = function() { | |
| return token; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'openssl' | |
| require 'Base64' | |
| key = "secret-key" | |
| data = "some data to be signed" | |
| Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pbcopy(str) | |
| IO.popen('pbcopy', 'r+') {|io| io.puts str } | |
| output.puts "-- Copy to clipboard --\n#{str}" | |
| end | |
| Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n| | |
| pbcopy _pry_.input_array[n ? n.to_i : -1] | |
| end | |
| Pry.config.commands.command "copy", "Copy to clipboard" do |str| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! ****************************** | |
| Handlebars helpers | |
| *******************************/ | |
| // debug helper | |
| // usage: {{debug}} or {{debug someValue}} | |
| // from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/) | |
| Handlebars.registerHelper("debug", function(optionalValue) { | |
| console.log("Current Context"); | |
| console.log("===================="); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| def RateLimited(maxPerSecond): | |
| minInterval = 1.0 / float(maxPerSecond) | |
| def decorate(func): | |
| lastTimeCalled = [0.0] | |
| def rateLimitedFunction(*args,**kargs): | |
| elapsed = time.clock() - lastTimeCalled[0] | |
| leftToWait = minInterval - elapsed | |
| if leftToWait>0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) 2011, Eng Eder de Souza | |
| # ___ _ _ ___ | |
| # | __|__| |___ _ _ __| |___ / __| ___ _ _ _____ _ | |
| # | _|/ _` / -_) '_| / _` / -_) \__ \/ _ \ || |_ / _` | | |
| # |___\__,_\___|_| \__,_\___| |___/\___/\_,_/__\__,_| | |
| #Accessing the Google API for speech recognition! | |
| #Open a file type Wav to speech recognition | |
| #This source does not require any external programs to perform audio conversions :-) | |
| #http://ederwander.wordpress.com/2011/11/06/accessing-the-google-speech-api-python/ | |
| #Eng Eder de Souza |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # current Git branch | |
| branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
| # v1.0.0, v1.5.2, etc. | |
| versionLabel=v$1 | |
| # establish branch and tag name variables | |
| devBranch=develop |