Skip to content

Instantly share code, notes, and snippets.

View dbl0null's full-sized avatar
👁️‍🗨️

Sergey Shiganov dbl0null

👁️‍🗨️
  • Saint Petersburg, Russia
View GitHub Profile
@iwill
iwill / semverCompare.js
Last active January 19, 2024 12:42
JavaScript - Comparison of Semantic Versioning
/**
* Semantic Versioning Comparing
* #see https://semver.org/
* #see https://stackoverflow.com/a/65687141/456536
* #see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options
*/
function semverCompare(a, b) {
if (a.startsWith(b + "-")) return -1
if (b.startsWith(a + "-")) return 1
return a.localeCompare(b, undefined, { numeric: true, sensitivity: "case", caseFirst: "upper" })
package main
import (
"bytes"
"encoding/json"
"fmt"
"image/jpeg"
"net"
"net/http"
"os"
@amotl
amotl / README.rst
Last active October 2, 2019 10:40
HTTP PUT file uploads from Shaka Packager to Nginx
@quasilyte
quasilyte / channels.go
Created November 8, 2018 09:44
Channel vs mutex vs atomic for synchronized counter
package benchmark
import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
)
var methods = {
setupVideoConference() {
console.log('setupVideoConference');
return this.makeLocalTracks()
.then(this.getToken)
.then(this.createRoom)
.then(this.publishLocalTracks)
.catch((e) => {
console.log('setupVideoConference', JSON.stringify(e));
});
@fracasula
fracasula / context_cancel.go
Last active May 19, 2022 20:49
GoLang exiting from multiple go routines with context and wait group
package main
// Here's a simple example to show how to properly terminate multiple go routines by using a context.
// Thanks to the WaitGroup we'll be able to end all go routines gracefully before the main function ends.
import (
"context"
"fmt"
"math/rand"
"os"
@docPhil99
docPhil99 / macFFmpeg.md
Last active April 30, 2024 20:43
Mac webcam FFmpeg

#Capture and stream a webcam To capture using the iSight camera on a Mac, or infact any other webcam connected to the Mac, we can use FFmpeg. First get a list of the devices installed.

ffmpeg -f avfoundation -list_devices true -i "" 

This will list the aviable video and audio devices.

The below will capture at 30fps and the set video size to a file. ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i "0:none" out.avi

@santisbon
santisbon / Search my gists.md
Last active July 14, 2024 18:07
How to search gists.

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@truongminh
truongminh / exe.js
Last active September 19, 2018 09:54
Run child process with node
const { spawn } = require('child_process');
const EventEmitter = require('events').EventEmitter;
const RESTART_DELAY = 3000;
const PREFIX = "<<<";
const SEPERATOR = " ";
const MAX_QUEUE_LENGTH = 100;
/**
* @typedef {{uri: string; data: any;}} IBaseMessage
@soareschen
soareschen / metaprogramming-with-proxy.js
Created September 25, 2017 07:49
Metaprogramming in JavaScript using proxy and with statement
/*
This code snippet demonstrates how to do metaprogramming
in JavaScript using proxy and with statement.
Run this in non-strict mode.
*/
const proxy = new Proxy({}, {
get(target, key) {
if(key === Symbol.unscopables) return {}
return `${key.toUpperCase()} `
},