Skip to content

Instantly share code, notes, and snippets.

@dmgl
dmgl / idle.py
Last active January 30, 2020 16:16
How to launch Idle from virtualenv
#!/usr/bin/env python
from idlelib.PyShell import main
if __name__ == '__main__':
main()
@mscdex
mscdex / test.js
Last active September 15, 2023 11:55
sharing sessions between node.js and php using redis
var express = require('express'),
app = express(),
cookieParser = require('cookie-parser'),
session = require('express-session'),
RedisStore = require('connect-redis')(session);
app.use(express.static(__dirname + '/public'));
app.use(function(req, res, next) {
if (~req.url.indexOf('favicon'))
return res.send(404);
@ChrisLTD
ChrisLTD / functions.php
Created May 8, 2014 16:22
Fix so you can preview ACF field changes in Wordpress admin
<?php
/*
Debug preview with custom fields
Taken from: http://support.advancedcustomfields.com/forums/topic/preview-solution/
See also: http://support.advancedcustomfields.com/forums/topic/2nd-every-other-post-preview-throws-notice/
*/
add_filter('_wp_post_revision_fields', 'add_field_debug_preview');
function add_field_debug_preview($fields){
$fields["debug_preview"] = "debug_preview";
return $fields;
@alopes
alopes / stopwords.txt
Created April 10, 2013 20:32
Portuguese stop words
de
a
o
que
e
do
da
em
um
para
@mharsch
mharsch / gist:5188206
Last active February 8, 2024 02:43
serve HLS (HTTP Live Streaming) content from node.js

HLS streaming from node

Provided that you already have a file or stream segmenter generating your .m3u8 playlist and .ts segment files (such as the ffmpeg 'hls' muxer), this little node server will serve up those files to an HLS compatible client (e.g. Safari). If you're using node for your streaming app already, this obviates the need to serve the HLS stream from a separate web server.

loosely based on https://gist.github.com/bnerd/2011232

// loosely based on https://gist.github.com/bnerd/2011232
// requires node.js >= v0.10.0
// assumes that HLS segmenter filename base is 'out'
// and that the HLS playlist and .ts files are in the current directory
@joesteinkamp
joesteinkamp / script.js
Created August 19, 2012 17:08
Load External CSS Styles Based on User Agent. Use for mobile CSS loading (saves loading time).
// Check if iPhone or iPod
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
var cssPath = "http://path.to/iPhone.css";
}
// Check if Android
if ((navigator.userAgent.match(/Android/i))) {
var cssPath = "http://path.to/Android.css";
}
@pazdera
pazdera / abstract_factory_example.py
Created July 24, 2011 13:37
Example of `abstract factory' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `abstract factory' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@pazdera
pazdera / gist:1099559
Created July 22, 2011 14:29
Factory Method design pattern example in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `factory method' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.