Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / gist:3081392
Created July 10, 2012 05:44
PostgreSQL: UPDATE if the row exists, INSERT if it doesn't exists (UPSERT)
CREATE OR REPLACE FUNCTION upsert_tableName(arg1 type, arg2 type) RETURNS VOID AS $$
DECLARE
BEGIN
UPDATE tableName SET col1 = value WHERE colX = arg1 and colY = arg2;
IF NOT FOUND THEN
INSERT INTO tableName values (value, arg1, arg2);
END IF;
END;
$$ LANGUAGE 'plpgsql';
@cecilemuller
cecilemuller / embed.html
Last active October 7, 2015 12:28
HTML5 Video and fallbacks
<video width="400" height="300" controls="controls" poster="video.jpg">
<!-- video format depending on what the browser supports -->
<source src="video.mp4" type="video/mp4" />
<source src="video.webm" type="video/webm" />
<source src="video.ogv" type="video/ogg" />
<!-- flash fallback if the browser doesn't support HTML5 -->
<object type="application/x-shockwave-flash" width="400" height="300" data="video.swf">
<param name="movie" value="video.swf" />
@cecilemuller
cecilemuller / list.md
Last active October 9, 2015 03:37
What features an App.net interface needs to replace Twitter as far as I'm concerned

Remaining:

  • a tiny code snipplet that less technical users can copy/paste on their website to show how many times it was already shared and/or how many people follow you

  • Windows 7 desktop app in the style of the good version of Tweetdeck (a.k.a the cross-platform AIR version, before Tweetdeck was bought by Twitter)

Already done:

@cecilemuller
cecilemuller / gist:3790859
Created September 26, 2012 21:52
Shorthand to iterate thru an array and get the current element in a variable, in pure Javascript
var myArray = ["aaaaa", "bbbbb", "ccccc"];
for (var i = 0, oneItem; oneItem = myArray[i]; i++){
console.log( oneItem );
}
@cecilemuller
cecilemuller / gist:4049939
Created November 10, 2012 04:42
jQuery: replace HTML contents with a smooth height animation
(function($){
$.fn.replace_html = function(html){
return this.each(function(){
var el = $(this);
el.stop(true, true, false);
var finish = {width: this.style.width, height: this.style.height};
var cur = {width: el.width() + "px", height: el.height() + "px"};
el.html(html);
var next = {width: el.width() + "px", height: el.height() + "px"};
el.css(cur).animate(next, 300, function(){el.css(finish);});
@cecilemuller
cecilemuller / gist:4051168
Created November 10, 2012 13:58
CSS3: Common and discretionary ligatures in OpenType fonts
-moz-font-feature-settings: "liga=1, dlig=1";
-ms-font-feature-settings: "liga", "dlig";
-o-font-feature-settings: "liga", "dlig";
-webkit-font-feature-settings: "liga", "dlig";
font-feature-settings: "liga", "dlig";
@cecilemuller
cecilemuller / text.md
Created November 11, 2012 14:05
Caractères spéciaux sur clavier AZERTY mac

Quelques caractères necessaires en programmation et qui ne sont pas forcément faciles à trouver sur un clavier Apple français:

  • { ALT + (

  • } ALT + )

  • [ ALT + SHIFT + (

  • ] ALT + SHIFT + )

  • | ALT + SHIFT + L

@n1k0
n1k0 / 404checker.js
Created January 11, 2013 10:55
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@cecilemuller
cecilemuller / get_combinations.php
Created February 1, 2013 03:13
PHP: Get all combinations of multiple arrays (preserves keys)
<?php
function get_combinations($arrays) {
$result = array(array());
foreach ($arrays as $property => $property_values) {
$tmp = array();
foreach ($result as $result_item) {
foreach ($property_values as $property_value) {
$tmp[] = array_merge($result_item, array($property => $property_value));
}
@cecilemuller
cecilemuller / readme.md
Last active December 16, 2015 08:39
Setup Typescript in FlashDevelop with minification via Google Closure

Installation

  1. First, install Flashdevelop and make sure to select Install JS Compiler.

  2. Then install NodeJS which conveniently installs both Node.JS and its package manager NPM.

  3. Finally, open a command line prompt (the shortcut is Windows + R) and run npm install -g typescript.

Per-project