Skip to content

Instantly share code, notes, and snippets.

@jmshal
jmshal / atob.js
Last active April 27, 2024 04:12
Node.js ponyfill for atob and btoa encoding functions
module.exports = function atob(a) {
return new Buffer(a, 'base64').toString('binary');
};
@joshisa
joshisa / URL Parsing
Created February 3, 2017 02:27
Parsing of URLs using bash sh scripting
#!/bin/bash
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${1/$proto/})"
# extract the user (if any)
userpass="$(echo $url | grep @ | cut -d@ -f1)"
pass="$(echo $userpass | grep : | cut -d: -f2)"
if [ -n "$pass" ]; then
@bellbind
bellbind / main.js
Last active April 27, 2024 04:12
[electron] Tray launcher example
"use strict";
// [run the app]
// $ npm install electron
// $ ./node_modules/.bin/electron .
const {app, nativeImage, Tray, Menu, BrowserWindow} = require("electron");
let top = {}; // prevent gc to keep windows
@sylvaindethier
sylvaindethier / server.js
Created June 26, 2017 09:36
NodeJS Express server for SPA
// Express
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const PORT = 9000;
const STATIC = path.resolve(__dirname, 'dist');
const INDEX = path.resolve(STATIC, 'index.html');
@Saccarab
Saccarab / merge-ffmpeg.js
Created June 9, 2019 08:54
fluent-ffmpeg merge audio with video
const command = ffmpeg()
const commandArray = []
command.addInput(`./best.mp4`)
command.addInput(`./best2.wav`)
commandArray.push(`[1]volume=0.1[a1]`)
command.addInput(`./voiceover.mp3`)
commandArray.push(`[2]volume=0.9[a2]`)
let ffmpegKeys = '[a1][a2]amix=inputs=2[a]'
commandArray.push(ffmpegKeys)
@luciopaiva
luciopaiva / _Full-socketio-client-and-server-example.md
Last active April 27, 2024 04:09
Full socket.io client and server example

Full socket.io client and server example

Last updated: 2021-02-21, tested with socket.io v3.1.1

This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

If you're looking for examples using frameworks, check these links:

@claytonrcarter
claytonrcarter / README.md
Last active April 27, 2024 04:09
Bash script to check GitLab pipeline status

A super simple bash script to check the status of a GitLab CI pipeline.

$ git push
...
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
"pending"
...
$ git pipeline-status
@Strykar
Strykar / myweechat.md
Last active April 27, 2024 04:09 — forked from pascalpoitras/config.md
My always up-to-date WeeChat configuration (weechat-dev)

WeeChat Screenshot

Add 4 pane layout

/window merge all
/eval /window splith ${calc:8 / ${window[gui_current_window].win_height} * 100 // 1}
/buffer add -switch highmon
/window splitv 40
/buffer ##news
/window splitv 75

/buffer exec.conky

@jchandra74
jchandra74 / binary2hex.cs
Created April 14, 2015 00:12
Binary to Hex String Conversion
public static string BinaryToHex(byte[] data)
{
if (data == null)
{
return null;
}
var array = new char[checked(data.Length*2)];
for (var i = 0; i < data.Length; i++)
{
@jchandra74
jchandra74 / FileUtil.cs
Last active April 27, 2024 04:08
Detect MimeType and File Extension based on filename and falling back to fileStream for signature detection (specific to .binary extension)
//mimetypes: http://www.sitepoint.com/web-foundations/mime-types-complete-list/
//https://technet.microsoft.com/en-us/library/ee309278(office.12).aspx
public static class FileUtil
{
public static string DetectFileType(string filename, Stream fileStream)
{
var ext = Path.GetExtension(filename);
if (string.IsNullOrEmpty(ext))
{