Skip to content

Instantly share code, notes, and snippets.

View yannickcr's full-sized avatar

Yannick Croissant yannickcr

View GitHub Profile
@yannickcr
yannickcr / String.SHA1.js
Created November 23, 2010 23:10
Hash a string with the SHA-1 algorithm (using MooTools)
/*
---
script: String.SHA1.js
description: Hash a string with the SHA-1 algorithm
license: MIT-style license.
authors: Yannick Croissant
@yannickcr
yannickcr / make-js.sh
Created March 25, 2011 00:49
A simple shell script to loop through your javascripts and give them to sprocket and uglifyjs
SOURCEPATH=/path/to/javascripts/sources
BUILDPATH=/path/to/compiled/javascripts
NODEPATH=/path/to/node
UGLIFYPATH=/path/to/uglifyjs
SPROCKETPATH=/path/to/sprocketize
cd $SOURCEPATH
for f in *.js;
do
@yannickcr
yannickcr / example.html
Created May 2, 2011 21:27
A simple JS snippet to execute your framework-dependant code when the (asynchronously loaded) framework is ready.
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>Example</title>
<script>
// Define an empty array
var Ready = [];
</script>
<script async src="main.js"></script>
<script>
@yannickcr
yannickcr / test.js
Created October 25, 2011 12:52
Ack / Grep
var util = require('util');
var exec = require('child_process').exec;
// Grep (ok)
exec("grep 'grep' test.js", function(){
console.dir(arguments);
});
// Ack (nok)
exec("ack 'ack' test.js", function(){
@yannickcr
yannickcr / social.js
Created February 28, 2012 15:59
Insert GooglePlus and Facebook buttons (use the HTML5 embedding code)
/*
* Google Plus
*
* Include Google Plus One if there is a "g-plusone" button in the page
*
*/
$(document).ready(function() {
if (!$('.g-plusone').length) return;
window.___gcfg = {lang: 'fr-FR'};
[
{ "keys": ["ctrl+m"], "command": "toggle_side_bar" }
]
@yannickcr
yannickcr / transmission.js
Created January 16, 2013 20:59
Small script to check the actives hosts on the network and, according to the results, start/stop the torrents. NB: The high priority torrents remains untouched.
// Small script to check the actives hosts on the network and, according to the results, start/stop the torrents.
// NB: The high priority torrents remains untouched.
//
// cron task to exec it every 5min: */5 * * * * root node /volume1/web/tasks/transmission/transmission.js > /dev/null
var Transmission = require('transmission'); // node-transmission - https://github.com/FLYBYME/node-transmission
var exec = require('child_process').exec;
// Log in to transmission
var transmission = new Transmission({
@yannickcr
yannickcr / set.js
Created June 5, 2013 09:41
Handlebars Set Helper: Capture a block of content and store it in a variable.
/*
* Usages:
* {{#set "content"}}
* captured content
* {{/set}}
* My {{ content }}
*/
Handlebars.registerHelper('set', function(name, options) {
this[name] = options.fn(this);
return null;
@yannickcr
yannickcr / emblem-CSS.js
Last active December 28, 2015 12:58
HTML5, JS, CSS3 and MDN emblems for Battlefield 4
emblem.emblem.load({
"objects": [
{
"opacity": 1,
"angle": -5.0043635188,
"flipX": false,
"flipY": false,
"top": 138,
"height": 298.3367253252,
"width": 20,
@yannickcr
yannickcr / highlights_full_line.patch
Created January 6, 2014 14:47
highlights_full_line option for SublimeLinter 3
lint/linter.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lint/linter.py b/lint/linter.py
index bb701df..bef4602 100644
--- a/lint/linter.py
+++ b/lint/linter.py
@@ -1258,13 +1258,17 @@ class Linter(metaclass=LinterMeta):
col = i
break