Skip to content

Instantly share code, notes, and snippets.

View gprasanth's full-sized avatar
💻
Todos.shift();

Prasanth gprasanth

💻
Todos.shift();
View GitHub Profile
@stonecharioteer
stonecharioteer / closures.py
Last active October 22, 2021 14:37
Python Closures - Bangpypers Lightning Talk 2021-10-22
"""Examples to show how Python stores the closure metadata in a decorator.
Know that this information isn't always just attached to a decorator. It could
also be passed around with regular functions, if the conditions match.
That is, if a variable from a higher scope is _referenced_ from a variable in
another scope, which is passed around, then, a __closure__ meta variable is
attached to the object that is passed around, where it has a store of what its
'closure' is.
@ryanburnette
ryanburnette / Caddyfile
Last active May 31, 2024 00:23
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@kayue
kayue / template.js
Created November 12, 2014 04:35
JS template engine
function t(s,d){
for(var p in d)
s=s.replace(new RegExp('{'+p+'}','g'),
typeof d[p][1]=='f' ? d[p]() : d[p]);
return s;
}
t("Hello {who}!", { who: "JavaScript" });
// "Hello JavaScript!"
@smokinjoe
smokinjoe / html5 boilerplate
Last active February 12, 2022 09:46
basic html5 boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
@willurd
willurd / web-servers.md
Last active June 17, 2024 09:38
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@kraz
kraz / make.bat
Last active March 13, 2019 16:52
Windows batch for simulating twitter bootstrap make functionality
@echo off
SET BOOTSTRAP=.\docs\assets\css\bootstrap.css
SET BOOTSTRAP_LESS=.\less\bootstrap.less
SET BOOTSTRAP_RESPONSIVE=.\docs\assets\css\bootstrap-responsive.css
SET BOOTSTRAP_RESPONSIVE_LESS=.\less\responsive.less
SET "CHECK= "
SET HR=##################################################
::Try to use the local build tools, if installed instead of global ones
@DazWorrall
DazWorrall / Output
Created February 9, 2012 13:06
Testing file upload handling in Flask
in upload handler
in file close
..
----------------------------------------------------------------------
Ran 2 tests in 0.021s
OK
@kayue
kayue / bootstrapping.js
Created April 12, 2011 18:51
Javascript bootstrapping
/**
* Namespacing
* All method start with "init" will be automatically called at start.
*/
var popbee = {}
popbee.body = $("body");
popbee.initHomepage = function() {
if(!popbee.body.hasClass("homepage") return; // return if not at homepage
@while0pass
while0pass / listchars.vim
Last active April 22, 2024 05:59
show/hide hidden characters in Vim
" hide hidden chars
:set nolist
" show hidden characters in Vim
:set list
" settings for hidden chars
" what particular chars they are displayed with
:set lcs=tab:▒░,trail:▓,nbsp:░
" or