Skip to content

Instantly share code, notes, and snippets.

View speed-of-light's full-sized avatar

Speed of Light speed-of-light

View GitHub Profile
@damonmaria
damonmaria / cognitoAwsCredentials.js
Last active May 31, 2021 10:13
Keeping Cognito user pool and AWS tokens refreshed in browser, symptoms if you need this is the error: "Invalid login token. Token expired: 1446742058 >= 1446727732"
import AWS from 'aws-sdk/global'
import eventEmitter from 'event-emitter'
import differenceInMilliseconds from 'date-fns/difference_in_milliseconds'
import minDate from 'date-fns/min'
// Set this to match your setup
const env = {
awsRegion: XXXX,
identityPoolId: XXXX,
userPoolId: XXXX,
@serv
serv / rails_cors_support_example.rb
Created July 19, 2014 07:11
Example of setting header to support CORS on Rails 4 API server side
module Api
module V0
class LinksController < ApplicationController
# THIS
before_action :set_headers
def show
@link = Link.find(params[:id])
render json: @link
end
class @BaseCtrl
@register: (app, name) ->
name ?= @name || @toString().match(/function\s*(.*?)\(/)?[1]
app.controller name, this
@inject: (annotations...) ->
ANNOTATION_REG = /^(\S+)(\s+as\s+(\w+))?$/
@annotations = _.map annotations, (annotation) ->
@benlesh
benlesh / app.js
Last active August 30, 2024 08:37
Angular - Basics of Unit Testing a Controller
var app = angular.module('myApp', []);
/* Set up a simple controller with a few
* examples of common actions a controller function
* might set up on a $scope. */
app.controller('MainCtrl', function($scope, someService) {
//set some properties
$scope.foo = 'foo';
$scope.bar = 'bar';
@tmaier
tmaier / custom_plan.rb
Created December 31, 2013 10:33
Add Sidekiq support to Zeus. Allows to run Sidekiq with `zeus sidekiq`
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def sidekiq
# Based on bin/sidekiq
require 'sidekiq/cli'
begin
cli = Sidekiq::CLI.instance
cli.parse
@plentz
plentz / nginx.conf
Last active September 16, 2024 17:52
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@jimothyGator
jimothyGator / README.md
Last active August 25, 2024 17:37
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@vishaltelangre
vishaltelangre / auto_install_sublime_packages.markdown
Last active May 24, 2021 15:15
[Automate Packages Installation in Sublime Text 2] -- Automatically install Sublime Text 2 packages (some necessary ones, w/o fucking crap ones which makes sublime alike hell!)
  • To install packages, every time pressing ' ctrl+shift+pPackage Control: Install Package is very cumbersome task... right?

  • After fresh installation of ST2, open it and ctrl+` and hit enter after pasting below line [(1)][1]:

  import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
  • Restart ST2.

  • Open terminal, and navigate to Sublime's dir under your home folder by below command and create file w/ name Package Control.sublime-settings there in:

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active September 15, 2024 10:33
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: