Skip to content

Instantly share code, notes, and snippets.

View vivekagr's full-sized avatar

Vivek Agarwal vivekagr

View GitHub Profile
@Ambroos
Ambroos / Ad.jsx
Created April 29, 2015 14:18
Loading synchronous / document.write-ing ads asynchronously against their will in a React component
import React from 'react';
import $script from 'scriptjs';
require('postscribe/htmlParser/htmlParser.js'); // This is required for postScribe, postScribe is a bit annoying.
const postscribe = require('exports?postscribe!postscribe'); // Needs webpack exports-loader! Otherwise, just require it and use window.postscribe.
// This GlobalAdCodePromise is a simple promise that uses script.js to load a javascript file and then resolve.
const GlobalAdCodePromise = new Promise((resolve) => {
setTimeout(() => {
$script('http://annoying.adprovider.com/ad.js', () => {
@iurisilvio
iurisilvio / admin.py
Last active December 15, 2015 21:49
Flask-SuperAdmin with basic authentication
'''
This code is an example of Flask-SuperAdmin app with basic authentication. Use it for anything you like.
Based on this snippet: http://flask.pocoo.org/snippets/8/
'''
import flask
from flask.ext.superadmin import Admin, expose, AdminIndexView as _AdminIndexView
from flask.ext.superadmin.model import ModelAdmin as _ModelAdmin
from flask.ext.sqlalchemy import SQLAlchemy
@hausen
hausen / gist:9501041
Last active August 29, 2015 13:57
"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

"Fixing" xkcd 1340 (or making the most redonkulous clock ever)

Update: feeling adventurous? Clone or fork the xkcd clock! If you just want to see it in action or get a glimpse of how it works, keep reading.

Problem

The date in [xkcd's comic number 1340][1] [does not change][2].