Skip to content

Instantly share code, notes, and snippets.

View markni's full-sized avatar
🏠
Working from home

Mark Ni markni

🏠
Working from home
View GitHub Profile
@lydell
lydell / draw-rect.js
Last active October 8, 2020 17:38
Visualize .getBoundingClientRect()
function draw(rect) {
const div = document.createElement("div");
// Might be needed on crazy pages, but makes the console output for the div crazy large.
// div.style.all = "unset";
div.style.position = "absolute";
div.style.zIndex = "2147483647";
// At least _try_ to scroll along. Won’t work for inner scroll.
div.style.left = `${window.scrollX + rect.left}px`;
div.style.top = `${window.scrollY + rect.top}px`;
div.style.width = `${rect.width}px`;
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@charlesdaniel
charlesdaniel / basic_auth_nodejs_test.js
Created January 27, 2012 02:53
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@csanz
csanz / encrypt_decrypt.js
Created August 30, 2011 16:06
Simple String Encryption & Decryption with Node.js
function encrypt(text){
var cipher = crypto.createCipher('aes-256-cbc','d6F3Efeq')
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');
return crypted;
}
function decrypt(text){
var decipher = crypto.createDecipher('aes-256-cbc','d6F3Efeq')
var dec = decipher.update(text,'hex','utf8')
@umq
umq / RotateDisplay.cs
Created May 23, 2011 12:44
Rotate secondary display with ChangeDisplaySettingsEx()
using System;
using System.Runtime.InteropServices;
namespace RotateDisplayTest
{
class RotateDisplay
{
static void Main(string[] args)
{
uint deviceID = 1; // zero origin (i.e. 1 means DISPLAY2)