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
  • 13:44 (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 August 22, 2024 05:03
Converts a javascript number from scientific notation to a decimal string
/**
* Removes the minus sign from the beginning of the string
*
* @param str
* @returns an array with the first item as true if a minus
* was found and the string minus the minus sign.
*/
function stripSign(str) {
// Check if it has a minus sign
let hasMinus = str.charAt(0) === '-';
@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 [email protected]: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