Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Srushtika / server.js
Last active October 14, 2021 11:21
WebSockets server tutorial
const http = require('http');
const crypto = require('crypto');
const static = require('node-static');
const file = new static.Server('./');
const server = http.createServer((req, res) => {
req.addListener('end', () => file.serve(req, res)).resume();
});
server.on('upgrade', function (req, socket) {
if (req.headers['upgrade'] !== 'websocket') {
socket.end('HTTP/1.1 400 Bad Request');
@ziaulrehman40
ziaulrehman40 / CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally overview.md
Last active August 30, 2020 15:10
CircleCI 2.0 Parallel builds SimpleCov coverage report merging locally

Simplecov aggregated coverage report from CircleCI 2.0 parallel builds (focused on storing locally/within CI containers as artifacts)

Problem Statement

We have Rails application which is running tests on circleCI 2.0, we have simplecov configured to track the coverage of our test suite. Now the problem is with parallelism enabled, we have partial coverage reports in all different containers according to the tests those containers ran.

We obviously want to have consolidated simplecov coverage report which actually shows us overall coverage report.

@afragen
afragen / raspi-setup-gitea.md
Last active December 20, 2023 16:47 — forked from mirhec/raspi-setup-gitea.md
Installing Gitea on Raspberry Pi 3 b+ with nginx and automatic backups

Setup Gitea on Raspberry Pi (3b+)

These instructions are based on this article: https://docs.gitea.io/en-us/install-from-source/.

Setup Raspberry Pi with minimal Raspbian image. You need to connect to the HDMI port and set the following:

Use Noobs to install Raspian.

Open menu Preferences > Raspberry Pi Settings

@JPvRiel
JPvRiel / apt_pinning_priorities.md
Last active April 22, 2024 19:42
Apt package pinning and priorities
@Daniel-Hug
Daniel-Hug / arr-stat.js
Last active December 11, 2023 14:46
JavaScript statistical functions for arrays: max, min, range, midrange, sum, mean / average, median, modes, variance, standard deviation, mean absolute deviation, z scores
var arr = {
max: function(array) {
return Math.max.apply(null, array);
},
min: function(array) {
return Math.min.apply(null, array);
},
range: function(array) {
@jamiew
jamiew / mp4box_hacks.sh
Created March 7, 2013 18:56
Adding subtitles and audio tracks to an MP4 video with MP4Box
# Add subtitle track
MP4Box -add minecraft_uncut.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" Minecraft2_mobile.mp4
# Add audio track
# 1. doesnt work in quicktime/itunes
MP4Box -add commentary_audio.aac Minecraft2_mobile.mp4
# 2. supposed to work in quicktime/itunes but doesn't seem to; :name at least is definitely not supported
MP4Box -add commentary_audio.aac:disable:group1:lang=en:name="Director's Commentary" Minecraft2_mobile.mp4
@letorbi
letorbi / require.js
Last active November 20, 2018 22:27
The first and now obsolete version of my Node.js' require function for browsers. Check https://github.com/letorbi/smoothie for a latest version.
// NEW VERSION AVAILABLE: Check out my GitHub repository at
// https://github.com/letorbi/smoothie for a new and improved version.
// Require() 0.3.4 unstable
//
// Copyright 2012,2013 Torben Haase <http://pixelsvsbytes.com/>
//
// Require() is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@notmasteryet
notmasteryet / hacks.js
Created July 1, 2011 05:26
Hack for IE to support pdf.js
(function() {
try {
var a = new Uint8Array(1);
return; //no need
} catch(e) { }
function subarray(start, end) {
return this.slice(start, end);
}
@nmrugg
nmrugg / static_server.js
Last active September 25, 2015 00:27
A simple node.js web server
/*jslint onevar: true, undef: true, newcap: true, nomen: true, regexp: true, plusplus: true, bitwise: true, node: true, indent: 4, white: false */
/// Usage: node static_server.js PORT
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs"),
qs = require("querystring"),
port = process.argv[2] || 80, /// Defaults to port 80