Skip to content

Instantly share code, notes, and snippets.

@advance512
advance512 / storeFirstTouchUTMParamsToCookie.js
Created May 27, 2018 16:23
Store the first-touch UTM parameters to cookie of main domain
var SelectomCookieToUTM = function() {
/* Cookie based on https://developers.livechatinc.com/blog/setting-cookies-to-subdomains-in-javascript/ */
var Cookie=function(){var a={set:function(b,d,e){var f,g,h,j,k;e?(h=new Date,h.setTime(h.getTime()+1e3*(60*(60*(24*e)))),j="; expires="+h.toGMTString()):j="",k=location.host,1===k.split(".").length?document.cookie=b+"="+d+j+"; path=/":(g=k.split("."),g.shift(),f="."+g.join("."),document.cookie=b+"="+d+j+"; path=/; domain="+f,(null==a.get(b)||a.get(b)!=d)&&(f="."+k,document.cookie=b+"="+d+j+"; path=/; domain="+f))},get:function(b){for(var g,d=b+"=",e=document.cookie.split(";"),f=0;f<e.length;f++){for(g=e[f];" "==g.charAt(0);)g=g.substring(1,g.length);if(0==g.indexOf(d))return g.substring(d.length,g.length)}return null},erase:function(b){a.set(b,"",-1)}};return a}();
var s = {
Cookie: Cookie,
getParameterByName: function(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return mat
@advance512
advance512 / Text.js
Created March 12, 2017 04:03 — forked from amannn/Text.js
Material-UI typography for version 0.x (based on SASS and CSS modules)
import React, {PropTypes} from 'react';
import cx from 'classnames';
import cs from './Text.scss';
/**
* Material-UI doesn't expose the Material Design typography in the
* current stable version, but the upcoming major version does so
* (https://github.com/callemall/material-ui/blob/next/src/Text/Text.js).
* As the upcoming relase is currently in alpha version, this
* component is back-ported so its API can already be used.
@advance512
advance512 / duplicate_dynamodb_table.py
Created January 20, 2015 23:08 — forked from iomz/duplicate_dynamodb_table.py
A tool to duplicate DynamoDB tables.
from traceback import print_exc
from boto.dynamodb2.exceptions import ValidationException
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
from boto.exception import JSONResponseError
from time import sleep
import sys
if len(sys.argv) != 3:
@advance512
advance512 / upsert.py
Last active August 29, 2015 14:12 — forked from timtadh/upsert.py
#!/usr/bin/env python
# Copyright (c) 2012, Tim Henderson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
@advance512
advance512 / s3_async_client.py
Last active August 18, 2019 19:59
S3 client that uses Tornado's asynchronous mechanisms. Allows the uploading and downloading of files asynchronously, including metadata support as well. Based on https://gist.github.com/taylanpince/5876491
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2011-2013 Everything.me. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.