Skip to content

Instantly share code, notes, and snippets.

@L2L2L
L2L2L / UDPSocket.cs
Created May 20, 2019 — forked from darkguy2008/UDPSocket.cs
Simple C# UDP server/client in 56 lines
View UDPSocket.cs
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDP
{
public class UDPSocket
{
private Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
@L2L2L
L2L2L / gist:ca4b3693cc13bfad1c1aa2bffbf1864f
Created Jul 23, 2018 — forked from podo/gist:5361182
Get Pseudo-Element Properties with JavaScript
View gist:ca4b3693cc13bfad1c1aa2bffbf1864f
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color')
@L2L2L
L2L2L / README
Last active Jan 26, 2018 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
View README
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
View new syntax ideal
(()=>{
const o = {arr:[1,2,3], obj:{a:1,b:2,c:3}};
const foo{arr:a,obj:o} = o;//making it easy to transfer data from one object to another
console.log(foo);//foo = {a:[1,2,3],o:{a:1,b:2,c:3}}
const bar = {baz:"foo",foo:"bar",bar:"baz"};
const poo = Object.assgin({},bar);//this would be okey if it offer filter in it their argument
const poo = Object.assgin({},bar,["baz","foo"]);
poo//{baz:"foo",foo:"bar"}
View json.stringify.js
function JSON_stringify(s, emit_unicode)
{
var json = JSON.stringify(s);
return emit_unicode ? json : json.replace(/[\u007f-\uffff]/g,
function(c) {
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4);
}
);
}
View svg2png.js
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@L2L2L
L2L2L / gist:1b76d274adccb542159a
Created Sep 8, 2014
understanding the readable stream
View gist:1b76d274adccb542159a
var Readable;
Readable = require("stream").Readable;
var readable;
readable = new Readable();
var i;
i = 0;
@L2L2L
L2L2L / gist:5928f56007770c58249e
Created Sep 7, 2014
this... and "use strict";
View gist:5928f56007770c58249e
"use strict"; //<= comment out strict mode after running it to see the output.
function self(){
console.log(this);
}
console.log("with gOPN this:" + Object.getOwnPropertyNames(this)); // => []
console.log("just cl this:" + this); // => {}
console.log("with gOPN this.__proto__:" + Object.getOwnPropertyNames(this.__proto__));
console.log("just cl this.__proto__:" + this.__proto__);
process.stdout.write("function self: ");
@L2L2L
L2L2L / Buffer's instance method read and write
Last active Aug 29, 2015
Replacement for all write and read method for Buffer's instance objects.
View Buffer's instance method read and write
"Use strict";
Buffer.prototype.read = function(index, dataType, offfset, end){
offset = offset||0;
end = end||this.length;
return (this["read"+dataType](index, offset, end));
View jqflower-test.html
<!DOCTYPE html>
<meta charset="utf-8" />
<label class="myItems">Hello</label>
<label class="myItems">World!</label>
<script src="jqflower.js"></script>
<script>
try {