Skip to content

Instantly share code, notes, and snippets.

@MinChanSike
MinChanSike / random.js
Created September 29, 2021 17:48
Random data in javascript
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
const countries = ["Singapore", "Malaysia", "Japan", "Korea", "USA", "UK", "Australia"];
function randomCountry(){
return countries[Math.floor(Math.random() * countries.length)]
@MinChanSike
MinChanSike / ffmpegToWeb.js
Created August 24, 2021 02:45 — forked from moeiscool/ffmpegToWeb.js
FFMPEG to Web Browser with Express, Socket.IO and JSMPEG
// Shinobi (http://shinobi.video) - FFMPEG H.264 over HTTP Test
// How to Use raw H.264 (Simulated RTSP)
// 1. Start with `node ffmpegToWeb.js`
// 2. Get the IP address of the computer where you did step 1. Example : 127.0.0.1
// 3. Open VLC and "Open Network Stream".
// 4. Input the following without quotes : `http://127.0.0.1:8001/h264` and start.
var child = require('child_process');
var io = require('socket.io');
var events = require('events');
btn Button chk CheckBox ckl CheckedListBox
cmb ComboBox dtp DateTimePicker lbl Label
llb LinkLabel lst ListBox lvw ListView
mtx MaskedTextBox cdr MonthCalendar icn NotifyIcon
nud NumeircUpDown pic PictureBox prg ProgressBar
rdo RadioButton rtx RichTextBox txt TextBox
tip ToolTip tvw TreeView wbs WebBrowser
??
flp FlowLayoutPanel grp GroupBox pnl Panel
@MinChanSike
MinChanSike / PartitionElementsByC#.cs
Last active December 15, 2020 02:08
Partition Elements By C#
public static class Extensions {
public static Dictionary<int, IEnumerable<T>> AdjustablePartition<T>(this IEnumerable<T> source, int count) {
var map = new Dictionary<int, IEnumerable<T>>();
var average = (int)Math.Round(source.Count() / (double)count);
for (int i = 0; i < count; i++) {
if (i == count - 1) {
var skipCount = (i) * average;
var takeCount = source.Count() - skipCount;
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@MinChanSike
MinChanSike / common_h264_codec_strings_used_in_youtube__no_parsing.js
Created April 9, 2020 06:21
H.264 Codec String Parser (video, profile, level) - August 2017
//"avcoti" hexadecimal representation of the following three bytes in the (subset) sequence parameter set Network Abstraction Layer (NAL) unit specified in AVC: 1.profile_idc, 2.the byte containing the constraint_set flags (currently constraint_set0_flag through constraint_set5_flag, and the reserved_zero_2bits), 3.level_idc.
AVC1_CODEC_MAP = {
,"avc1.66.30": {profile:"Baseline", level:3.0, max_bit_rate:10000} //iOS friendly variation (iOS 3.0-3.1.2)
"avc1.42001e": {profile:"Baseline", level:3.0, max_bit_rate:10000}
,"avc1.42001f": {profile:"Baseline", level:3.1, max_bit_rate:14000}
//other variations
,"avc1.77.30": {profile:"Main", level:3.0, max_bit_rate:10000} //iOS friendly variation (iOS 3.0-3.1.2)
,"avc1.4d001e": {profile:"Main", level:3.0, max_bit_rate:10000}
,"avc1.4d001f": {profile:"Main", level:3.1, max_bit_rate:14000}
@MinChanSike
MinChanSike / util.css
Created April 1, 2019 03:46
Utilities for css
/**************************/
/* Credit: colorlib.com */
/**************************/
/*[ FONT SIZE ]
///////////////////////////////////////////////////////////
*/
.fs-1 {font-size: 1px;}
.fs-2 {font-size: 2px;}
.fs-3 {font-size: 3px;}
@MinChanSike
MinChanSike / DateTimeTest.cs
Created March 28, 2019 04:25
Date Time vs DateTimeOffset
var now = DateTime.Now;
var nowUTC = now.ToUniversalTime();
var nowOffset = new DateTimeOffset(now);
var nowUTCOffset = new DateTimeOffset(nowUTC);
DateTimeOffset nowWithOffset = now;
now.Dump("Now");
nowUTC.Dump("Now UTC");
nowOffset.Dump("Now Offset");
nowUTCOffset.Dump("Now UTC Offset");
@MinChanSike
MinChanSike / mStyle.css
Last active March 4, 2019 02:21
CSS Content Center
.container {
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}