Skip to content

Instantly share code, notes, and snippets.

@monolithed
monolithed / proportional-scale.js
Created October 24, 2022 17:36 — forked from ariona/proportional-scale.js
Proportionally Scale Any HTML Content
var $el = $("#very-specific-design");
var elHeight = $el.outerHeight();
var elWidth = $el.outerWidth();
var $wrapper = $("#scaleable-wrapper");
$wrapper.resizable({
resize: doResize
});
@monolithed
monolithed / strace.md
Created August 14, 2018 12:56 — forked from graste/strace.md
strace process for network and memory and other syscalls

File activity

strace -e trace=file -fp PID (file) or strace -e trace=desc -fp PID (file descriptors)

Common calls:

  • access
  • close – close file handle
  • fchmod – change file permissions
  • fchown – change file ownership
@monolithed
monolithed / html5-video-streamer.js
Created July 4, 2017 16:42 — forked from paolorossi/html5-video-streamer.js
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
// Usage
<Router>
<Provider store={store}>
<ListeningRouter>
<Main />
</ListeningRouter>
</Provider>
</Router>
@monolithed
monolithed / file.js
Created April 24, 2017 07:28 — forked from alexcorvi/file.js
JSX without react
var React = {
createElement: function (tag, attrs, children) {
var e = document.createElement(tag);
// Add attributes
for (var name in attrs) {
if (name && attrs.hasOwnProperty(name)) {
var v = attrs[name];
if (v === true) {
e.setAttribute(name, name);
openssl genrsa -out privkey.pem 768
openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey2.pem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@monolithed
monolithed / index.html
Last active February 1, 2017 18:23 — forked from iketari/index.html
Object.keys vs for..in #jsbench #jsperf (http://jsbench.github.io/#9edc79f26350c0e90d8dddb48dc19f31) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Object.keys vs for..in #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@monolithed
monolithed / nginx.conf
Created December 24, 2015 10:18 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
@monolithed
monolithed / index.js
Created December 7, 2015 12:24 — forked from lygaret/index.js
ES6 Quasi-Literal for JSX
define(function(require) {
var React = require('react');
var paramRegex = /__(\d)+/;
var parser = new DOMParser();
var errorDoc = parser.parseFromString('INVALID', 'text/xml');
var errorNs = errorDoc.getElementsByTagName("parsererror")[0].namespaceURI;
// turns the array of string parts into a DOM
// throws if the result is an invalid XML document.