Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Deering sdeering

View GitHub Profile
@dmlogic
dmlogic / AngularTrait.php
Last active Aug 29, 2015
Securing Angular with Laravel
View AngularTrait.php
<?php namespace MyApp\Response;
use Cookie;
use Request;
use Session;
use Symfony\Component\HttpFoundation\Cookie as SymfonyCookie;
trait AngularTrait {
/**
@sdeering
sdeering / gist:7153714
Last active Dec 26, 2015
Basic Node.js Crypto Cipher Encryption Example
View gist:7153714
var cryptojs = require('crypto')
, salt = "<client app salt token>"
, keyIterations = 1000 //number of interations to generate your key
, keyLength
, key
, password
, cipher
, msg = "<what you want to encrypt>"
, encryptedMsg;
@davemo
davemo / bootstrap.js
Last active Nov 16, 2017
injectorsauce
View bootstrap.js
(function() {
var $injector = angular.injector(['ng']);
$injector.invoke(function($http) {
// this works!
$http.get("/auth/csrf_token").then(function(response) {
angular.module("app").constant("CSRF_TOKEN", response.csrf_token);
angular.bootstrap(document, ['app']);
});
@randomecho
randomecho / australian-postcodes.sql
Last active Aug 21, 2020
Australian postcodes (with states and suburb names) geocoded with latitude and longitude.
View australian-postcodes.sql
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@adrianbravo
adrianbravo / encrypt-decrypt.js
Created Sep 22, 2011
Basic Node.js crypto cipher/decipher example.
View encrypt-decrypt.js
var crypto = require('crypto')
, key = 'salt_from_the_user_document'
, plaintext = 'password'
, cipher = crypto.createCipher('aes-256-cbc', key)
, decipher = crypto.createDecipher('aes-256-cbc', key);
cipher.update(plaintext, 'utf8', 'base64');
var encryptedPassword = cipher.final('base64')
decipher.update(encryptedPassword, 'base64', 'utf8');
You can’t perform that action at this time.