Skip to content

Instantly share code, notes, and snippets.

@L2L2L
L2L2L / UDPSocket.cs
Created May 20, 2019 23:52 — forked from darkguy2008/UDPSocket.cs
Simple C# UDP server/client in 56 lines
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 July 23, 2018 13:57 — forked from podo/gist:5361182
Get Pseudo-Element Properties with JavaScript
var color = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('color')
@L2L2L
L2L2L / README
Last active January 26, 2018 19:54 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
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
(()=>{
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"}
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);
}
);
}
@L2L2L
L2L2L / svg2png.js
Last active August 29, 2015 14:11 — forked from gustavohenke/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 September 8, 2014 02:03
understanding the readable stream
var Readable;
Readable = require("stream").Readable;
var readable;
readable = new Readable();
var i;
i = 0;
@L2L2L
L2L2L / gist:5928f56007770c58249e
Created September 7, 2014 01:15
this... and "use strict";
"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 August 29, 2015 14:05
Replacement for all write and read method for Buffer's instance objects.
"Use strict";
Buffer.prototype.read = function(index, dataType, offfset, end){
offset = offset||0;
end = end||this.length;
return (this["read"+dataType](index, offset, end));
<!DOCTYPE html>
<meta charset="utf-8" />
<label class="myItems">Hello</label>
<label class="myItems">World!</label>
<script src="jqflower.js"></script>
<script>
try {