Skip to content

Instantly share code, notes, and snippets.

View ArthurBeaulieu's full-sized avatar
:octocat:
OUI

Arthur Beaulieu ArthurBeaulieu

:octocat:
OUI
  • Dassault Systèmes
  • Paris
  • 10:16 (UTC +02:00)
  • X @a_Messmaker
View GitHub Profile
@zfael
zfael / nodejs.checksum.js
Created June 20, 2017 13:57
NODE.JS - How to generate file's Checksum (CRYPTO)
var fs = require('fs');
var crypto = require('crypto');
fs.readFile('file.pdf', function(err, data) {
var checksum = generateChecksum(data);
console.log(checksum);
});
function generateChecksum(str, algorithm, encoding) {
return crypto
@leobalter
leobalter / karma.conf.js
Created November 12, 2015 23:01 — forked from frederickfogerty/karma.conf.js
Coverage + tests with webpack, babel, karma, mocha, and istanbul
var webpack = require('webpack')
module.exports = function (config) {
config.set({
browsers: [ 'Chrome' ], //run in Chrome
browserNoActivityTimeout: 60000,
singleRun: true, //just run once by default
frameworks: [ 'mocha' ], //use the mocha test framework
files: [
//'src/**/*.{jsx,js}',
@jiggzson
jiggzson / scientificToDecimal.js
Last active December 25, 2022 21:03
Converts a javascript number from scientific notation to a decimal string
var scientificToDecimal = function (num) {
var nsign = Math.sign(num);
//remove the sign
num = Math.abs(num);
//if the number is in scientific notation remove it
if (/\d+\.?\d*e[\+\-]*\d+/i.test(num)) {
var zero = '0',
parts = String(num).toLowerCase().split('e'), //split into coeff and exponent
e = parts.pop(), //store the exponential part
l = Math.abs(e), //get the number of zeros
@igrigorik
igrigorik / index.html
Created June 8, 2013 22:36
XHR streaming example
<p>Hello
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', '/stream');
xhr.seenBytes = 0;
xhr.onreadystatechange = function() {
console.log("state change.. state: "+ xhr.readyState);
@Valodim
Valodim / gist:5225460
Created March 22, 2013 23:11
rendering a moodbar .mood file as an svg with d3 in javascript
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
// takes .mood files from moodbar as input
var files = [
"05 - Awolnation - Jump On My Shoulders.mood"
];
files.forEach(function(f) {
@redteam-snippets
redteam-snippets / decimalToFraction.js
Created October 22, 2012 21:02
JavaScript: Decimal To Fraction
// Adapted from: http://bateru.com/news/2011/11/improved-code-for-javascript-decimal-to-fraction/
function gcd(a, b) {
return (b) ? gcd(b, a % b) : a;
}
var decimalToFraction = function (_decimal) {
var top = _decimal.toString().replace(/\d+[.]/, '');
var bottom = Math.pow(10, top.length);
if (_decimal > 1) {
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream