Skip to content

Instantly share code, notes, and snippets.

johnchristopher / on-duplicate-key-update.sql
Last active Aug 29, 2015
Update field if it exists or insert it if it doesn't (with MySQL ON DUPLICATE KEY UPDATE)
View on-duplicate-key-update.sql
mysql > CREATE TABLE `mytable` (
`myvalue` int(11) NOT NULL,
`myothervalue` int(11) NOT NULL,
UNIQUE KEY `myvalue_unique` (`myvalue`), -- C'est le champ qui s'il existe alors on le met à jour,
KEY `myvalue_idx` (`myvalue`) -- sinon on crée un nouvel enregistrement
Query OK, 0 rows affected (0.09 sec)
View gist:6c5f516a9ff55d3cee75
{"nbformat_minor": 0, "cells": [{"execution_count": 2, "cell_type": "code", "source": "%matplotlib inline\nfrom pylab import *\nx=linspace(0, 2*pi)\ny=sin(x)\nplot(x, y)", "outputs": [{"execution_count": 2, "output_type": "execute_result", "data": {"text/plain": "[<matplotlib.lines.Line2D at 0x60abad0>]"}, "metadata": {}}, {"output_type": "display_data", "data": {"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEACAYAAAC9Gb03AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHwJJREFUeJzt3Xe4XWWZ/vHvDQGRLqiAwFBDCD3gL6KIRMqQgAYYpYQq\nNYAxFBs4/DSA46CgtAwgECAQDFKVDkESQFFM6JIEQslMqKJSBKQEnvljLcZDOGXvs8u71tr357q4\ncvY5e+91k5w858m73qKIwMzMqmuh1AHMzKy1XOjNzCrOhd7MrOJc6M3MKs6F3sys4lzozcwqruFC\nL+kCSS9IeriX55whaY6kByUNafSaZmZWu2Z09BcCw3v6oqQdgLUjYiBwCHB2E65pZmY1arjQR8Rd\nwEu9PGUkMDF/7j3AspJWaPS6ZmZWm3aM0a8MzOvy+GlglTZc18zMaN/NWC3w2PsumJm1yYA2XOMZ\nYNUuj1fJP/cBklz8zcz6ISIWbKY/oB2F/lpgDHCZpM2BlyPihe6e2FfYIpM0LiLG9f/1DAZOAD4P\nnAXcCcyI4PUaX78csAfwNbIfppOAiyKY2fdrG8uemvOn5fxp1dIkN2N65WTgbmCQpHmSDpA0WtJo\ngIi4EXhS0uPAz4HDG71m
View gist:d69a85a539634d4961e3
{"nbformat_minor": 0, "cells": [{"execution_count": 2, "cell_type": "code", "source": "s='12'", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "map(int, s)", "outputs": [{"execution_count": 3, "output_type": "execute_result", "data": {"text/plain": "[1, 2]"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "Note que `int` est invoqu\u00e9 sans les parenth\u00e8ses.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "[int(x) for x in s]", "outputs": [{"execution_count": 4, "output_type": "execute_result", "data": {"text/plain": "[1, 2]"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "List comprehension. C'est d\u00e9j\u00e0 plus _pythonic_ comme ils disent.", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "filter(lambda l: l == '1', s)", "outputs": [{"execution_count": 14, "o
pandoc -s -S --toc -c github-pandoc.css -t html5 -o output.html
johnchristopher / gist:b011fc648c3637420444
Last active Aug 29, 2015 — forked from stran12/gist:1394757
How to install cGit on Nginx (Ubuntu server)
View gist:b011fc648c3637420444

How to install cGit on Nginx (Ubuntu server)

Step-by-step installtion of cGit on nginx without funky rewrite rules.


This is for

ffmpeg -i input.mp4 \
-map 0:1 \
-c:a copy \
-y output.m4a
johnchristopher / 0_reuse_code.js
Created Jun 18, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#! /bin/sh
sed 's/t p/t-p/gi' $1 |
sed 's/c s/c-s/gi' |
sed 's/c e/c-e/gi' |
sed 's/d p/d-p/gi' |
sed 's/N s/N-s/gi' |
sed 's/l I/l-I/gi' |
sed 's/P A/P-A/gi' |
View gist:5128574
# Last modified: 2011 Dec 14
# Version 0.9
# Author: Florian CROUZAT <>
# Feel free to do whatever you want with this file.
# Just make sure to credit what deserve credits.
# Arg(s): $1 - Arte+7 html URL of the page used to actually see the video.