Skip to content

Instantly share code, notes, and snippets.

@framp
framp / S3Policy.js
Created April 19, 2015 17:21
S3 Policy generator
var crypto = require('crypto');
var config = require('config');
module.exports = function(app) {
app.get('/s3-policy', function(req, res, next) {
var data = {
'expiration': new Date(+ new Date + 864e5).toISOString(),
'conditions': [{
'bucket': config.s3.bucket
}, {
@framp
framp / flatten.js
Last active October 31, 2017 12:00
Iterative flatten indefinite nested array
function flatten(input) {
if (!input) return
var output = [];
while(input.length)
if(input[0] instanceof Array)
input.unshift.apply(input, input.shift())
else
output.push(input.shift())
return output
}
<!DOCTYPE html>
<html>
<head>
<script src="./react-with-addons.js"></script>
<script src="./JSXTransformer.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/jsx">
var Item = React.createClass({
<!DOCTYPE html>
<html>
<head>
<script src="./react-with-addons.js"></script>
<script src="./JSXTransformer.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/jsx">
var Item = React.createClass({
useradd -mrU git
mkdir /home/git/.ssh
chmod 700 /home/git/.ssh
cp /root/.ssh/authorized_keys /home/git/.ssh
chmod 600 .ssh/authorized_keys
chsh -s /usr/bin/git-shell git
mkdir /home/git/apps.git
cd /home/git/apps.git
git init --bare
export DEPLOYDIR=/location/of/your/stuff
@framp
framp / markdown.css
Last active August 29, 2015 14:21 — forked from imjasonh/markdown.css
ready to take over every website !important
* {
font-size: 12pt !important;
font-family: monospace !important;
font-weight: normal !important;
font-style: normal !important;
text-decoration: none !important;
color: black !important;
cursor: default !important;
background: none !important;;
width: auto !important;
@framp
framp / 00-guest-porthole-index.html
Last active August 29, 2015 14:23
Porthole remote requester
<!DOCTYPE html>
<html>
<head>
<title>Proxy</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/porthole.min.js"></script>
<script type="text/javascript">
var parentDomain = 'PARENTDOMAIN'
var windowProxy;
window.onload=function(){
@framp
framp / trick.js
Created September 10, 2015 13:05
Get URLs from swagger-ui
var nodes = document.querySelectorAll('.path .toggleOperation')
Array.prototype.slice.apply(nodes).map(function(v){ return v.text })
var a = [{ value:"4a55eff3-1e0d-4a81-9105-3ddd7521d642", display:"Jamsheer"}, { value:"644838b3-604d-4899-8b78-09e4799f586f", display:"Muhammed"}, { value:"b6ee537a-375c-45bd-b9d4-4dd84a75041d", display:"Ravi"}, { value:"e97339e1-939d-47ab-974c-1b68c9cfb536", display:"Ajmal"}, { value:"a63a6f77-c637-454e-abf2-dfb9b543af6c", display:"Ryan"}];
var b = [{ value:"4a55eff3-1e0d-4a81-9105-3ddd7521d642", display:"Jamsheer", $$hashKey:"008"}, { value:"644838b3-604d-4899-8b78-09e4799f586f", display:"Muhammed", $$hashKey:"009"}, { value:"b6ee537a-375c-45bd-b9d4-4dd84a75041d", display:"Ravi", $$hashKey:"00A"}, { value:"e97339e1-939d-47ab-974c-1b68c9cfb536", display:"Ajmal", $$hashKey:"00B"}];
var onlyInFirst = function(equal, a, b){
return a.filter(function(current){
return b.filter(equal(current)).length == 0
});
}
var onlyInFirstMyObject = onlyInFirst.bind(0, function equal(a){
return function(b){
const equal = (a, b) => a === b
const create = (...args) => {
const rules = []
const creator = {
when(arg, valid, value, definition) {
const key = args.indexOf(arg)
rules[key] = rules[key] || []
rules[key].push([ (a) => valid(a, value), definition ])
return creator