Skip to content

Instantly share code, notes, and snippets.

View samsonradu's full-sized avatar
💭
We were promised flying cars, instead we got 140 characters.

Samson Radu samsonradu

💭
We were promised flying cars, instead we got 140 characters.
View GitHub Profile
@AbidRahman-MSFT
AbidRahman-MSFT / Ooxml footnotes.WORD.yaml
Last active November 18, 2021 14:36
Replace selection with sample text and footnote using Ooxml.
name: Ooxml footnotes
description: Replace selection with sample text and footnote using Ooxml.
host: WORD
api_set: {}
script:
content: >
$("#run").click(() => tryCatch(run));
const prefix = `<?xml version="1.0" encoding="UTF-8"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"><pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId4" Type="http://schemas.openxmlform

Composants d'une montre

Boîtier

  • Materiaux: Acier (inoxydable), Titanium, Or etc.
  • Composants: Couronne, Lunette

Mouvement

  • Mécanique: Automatique/Manuelle

Ceux-ci enmagasinent de l'énergie grâce aux mouvements naturels du poignet du porteur de la montre grâce à l'ajout d'un rotor (aussi appelé masse oscillante) qui remonte le ressort principal de manière perpétuelle, un système inventé par Rolex en 1930

// Originally taken from https://github.com/mgtitimoli/await-mutex
class Mutex {
constructor() {
this._locking = Promise.resolve();
this._locked = false;
}
isLocked() {
return this._locked;
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@samsonradu
samsonradu / gist:92006d38d6b76cbfa7ef
Last active June 20, 2016 12:09
Browser Console output in a div (for mobile devices without a console view)
function consolify(el){
var oLog = console.log;
var oWarn = console.warn;
var oErr = console.error;
console.log = console.info = function(message){
if (oLog)
oLog.call(console, message);
write(message, el, "info");
};
@joashp
joashp / openssl_encrypt_decrypt.php
Created September 4, 2015 15:59
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/
@magnetikonline
magnetikonline / README.md
Last active December 14, 2023 06:45
Nginx FastCGI cache configuration example.

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
@samsonradu
samsonradu / gist:5786092
Last active December 18, 2015 12:58
Vim usefull tips
## multi screens
:split/:vsplit - splits screens
crtl+w & arrows - navigate through windows
ctrl+w & < > ** resize horizontal screen
ctrl+w & + - ** resize vertical screen
Exit and go back to editor:
ctrl+z --> fg
@jboner
jboner / latency.txt
Last active May 1, 2024 14:21
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD