Skip to content

Instantly share code, notes, and snippets.

View slonoed's full-sized avatar
🥔

Dmitry Manannikov slonoed

🥔
View GitHub Profile
@slonoed
slonoed / jump_out_of_chrome_sandbox.js
Created November 3, 2012 15:08 — forked from tavisrudd/jump_out_of_chrome_sandbox.js
notes on how to break out of chrome extension content script sandboxes and eval code in page context
// Chrome extension 'content scripts' run in a sandboxed 'isolated world'
// (http://code.google.com/chrome/extensions/content_scripts.html#execution-environment).
// However, there are ways to get out and execute js code in the page
// context. Google searching revealed the following ways:
////////////////////////////////////////////////////////////////////////////////
// http://blog.afterthedeadline.com/2010/05/14/how-to-jump-through-hoops-and-make-a-chrome-extension/
// it looks like jQuery must be loaded by the content-script
jQuery('body').append('<script type="text/javascript">(function(l) {
var res = document.createElement('SCRIPT');
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
/**
* Use em or rem font-size in Bootstrap 3
*/
@font-size-root: 14px;
@font-unit: 0rem; // Pick em or rem here
// Convert all variables to em
/**
* Use em or rem font-size in Bootstrap 3
*/
@font-size-root: 14px;
@font-unit: 0rem; // Pick em or rem here
// Convert all variables to em
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • ➕ when adding feature
  • ➖ when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug
@slonoed
slonoed / lambda-dynamo
Created February 26, 2016 21:17 — forked from markusklems/lambda-dynamo
Short aws lambda sample program that puts an item into dynamodb
// create an IAM Lambda role with access to dynamodb
// Launch Lambda in the same region as your dynamodb region
// (here: us-east-1)
// dynamodb table with hash key = user and range key = datetime
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({apiVersion: '2012-08-10'});
exports.handler = function(event, context) {
function! s:encodeURIComponent(str)
let s = ''
for i in range(strlen(a:str))
let c = a:str[i]
if c =~# "[A-Za-z0-9-_.!~*'()]"
let s .= c
else
let s .= printf('%%%02X', char2nr(a:str[i]))
endif
endfor
@slonoed
slonoed / testEpic.js
Last active September 21, 2017 13:06 — forked from mordaha/testEpic.js
async function retry(foo, count = 1, delay) {
let error;
while (count--) {
try {
return foo()
} catch (e) {
error = e
await timeout(delay)
}