Skip to content

Instantly share code, notes, and snippets.

View akillamac's full-sized avatar

Renaud Bouissière akillamac

View GitHub Profile
@mxriverlynn
mxriverlynn / findkey.js
Created November 20, 2012 03:48
Find key by value, with underscore.js
function findKey(obj, value){
var key;
_.each(_.keys(obj), function(k){
var v = obj[k];
if (v === value){
key = k;
}
});
@nikmartin
nikmartin / A: Secure Sessions Howto
Last active July 2, 2024 05:59
Secure sessions with Node.js, Express.js, and NginX as an SSL Proxy
Secure sessions are easy, but not very well documented.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [PUBLIC INTERNET] <-> [CLIENT]
Edit for express 4.X and >: Express no longer uses Connect as its middleware framework, it implements its own now.
@omarstreak
omarstreak / background.js
Last active October 22, 2023 15:44
Chrome API Extension
//oauth2 auth
chrome.identity.getAuthToken(
{'interactive': true},
function(){
//load Google's javascript client libraries
window.gapi_onload = authorize;
loadScript('https://apis.google.com/js/client.js');
}
);
@chriseidhof
chriseidhof / LICENSE
Last active July 16, 2019 13:14
A tiny networking library
Copyright 2015 Chris Eidhof
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE
@amochohan
amochohan / 01_Laravel 5 Simple ACL manager_Readme.md
Last active July 16, 2024 18:08
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@mchirico
mchirico / TableViewController.swift
Created October 19, 2015 16:06
TableViews with animation...trying to come up with something simple here, or easy reference. This needs to be cleaned up.
//
// TableViewController.swift
// TableView
//
// Created by Mike Chirico on 10/18/15.
// Copyright © 2015 Mike Chirico. All rights reserved.
//
// http://www.raywenderlich.com/63089/cookbook-moving-table-view-cells-with-a-long-press-gesture
// Delete:
import UIKit
// MARK: Method chaining
class MethodChaining {
func fetchImage() -> Fetch<UIImage> {
let fetch = Fetch<UIImage>()
if let image = UIImage(named: "cat.jpg") {
if let succeed = fetch.succeed {
// never called because its nil
@mchirico
mchirico / VCMap.swift
Created November 2, 2015 22:28
Quick and dirty...creating a map in swift, using MKMapView
import UIKit
import MapKit
class VCMap: UIViewController {
@IBOutlet weak var map: MKMapView!
override func viewDidLoad() {
@amritk
amritk / dragdrop.js
Last active April 19, 2017 18:33
Trying to get this dragdrop from this codrops article working on the latest version of dragabilly
/**
* dragdrop.js
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2014, Codrops
* http://www.codrops.com
*
import UIKit
extension UIImage {
// colorize image with given tint color
// this is similar to Photoshop's "Color" layer blend mode
// this is perfect for non-greyscale source images, and images that have both highlights and shadows that should be preserved
// white will stay white and black will stay black as the lightness of the image is preserved
func tint(tintColor: UIColor) -> UIImage {