Skip to content

Instantly share code, notes, and snippets.

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

Chien Tran chientrm

🏠
Working from home
View GitHub Profile
@chientrm
chientrm / gtm.svelte
Created January 25, 2024 06:44
SvelteKit Google Tag Manager
onMount(() => {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
const gtmScript = document.createElement('script');
gtmScript.src = 'https://www.googletagmanager.com/gtm.js?id=' + PUBLIC_TAG_ID;
document.head.append(gtmScript);
});
sudo dd if=/dev/zero of=/swapfile0 bs=1M count=4096 status=progress # not right for btrfs? Should disable compression too?
sudo chmod 600 /swapfile0
# old kernels need more swapfiles
sudo lvcreate -l +100%FREE ubuntu-vg -n zram0
# edit the other two files in this gist first
sudo /usr/bin/init-zram-swapping
sudo sysctl -p
@Erisa
Erisa / cfd-termux.sh
Last active April 17, 2024 13:01
Install the Cloudflare Daemon (cloudflared) in Termux
#!/bin/sh
echo 'NOTE: You can now install cloudflared directly from Termux repos.'
echo 'NOTE: To install it from source instead, open the script and comment out the next two lines.'
pkg install cloudflared
exit
# ^ comment out these lines to proceed with the script
echo "--upgrading packages"
yes "" | pkg update
@1uokun
1uokun / createElement.js
Created September 25, 2018 08:10
React.createElement
const React = {
createElement: function (tag, attrs, children) {
var element = document.createElement(tag);
for (let name in attrs) {
if (name && attrs.hasOwnProperty(name)) {
let value = attrs[name];
if (value === true) {
element.setAttribute(name, name);
} else if (value !== false && value != null) {
@nic0lette
nic0lette / MainActivity.kt
Created May 25, 2018 23:58
Example of using AccountManager.newChooseAccountIntent without GET_ACCOUNTS permission
/*
* Copyright 2018 Google LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@siwalikm
siwalikm / aes-256-cbc.js
Last active April 26, 2024 12:34
AES-256-CBC implementation in nodeJS with built-in Crypto library
'use strict';
const crypto = require('crypto');
const ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b"; // set random encryption key
const IV = "5183666c72eec9e4"; // set random initialisation vector
// ENC_KEY and IV can be generated as crypto.randomBytes(32).toString('hex');
const phrase = "who let the dogs out";
var encrypt = ((val) => {
@eddieh
eddieh / libevent-v-libuv.md
Last active March 7, 2024 20:33
libevent vs libuv

libevent vs libuv

Comparing libevent and libuv. My upfront biased: I want to like libevent. However, I want to objectively compare the two and make an informed decision.

What versions are we comparing?

  • libevent 2.0.22 (Stable) [2014-01-05]
  • libuv 1.8.0 (Stable) [2015-12-15]
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 30, 2024 18:17
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@kitek
kitek / gist:1579117
Created January 8, 2012 17:50
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");