Skip to content

Instantly share code, notes, and snippets.

@sourceperl
sourceperl / say_cpu_temp.py
Last active February 18, 2021 14:45
Text to speak software with espeak and mbrola. Test on Raspberry Pi2 (Raspbian/jessie) and Pi4 (Raspbian/buster).
#!/usr/bin/env python3
import os, time
while True:
with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f:
cpu_temp = round(float(f.read()) / 1000)
os.system('espeak -v mb-fr1 -s 95 \'La température de la CPU est de %s degrés.\'' % cpu_temp)
time.sleep(2.0)
@weipah
weipah / import-portatour.ps1
Last active March 4, 2024 22:34
PowerShell V3 Multipart/formdata example with REST-API (Invoke-RestMethod)
function Import-Portatour {
param (
[parameter(Mandatory=$True,Position=1)] [ValidateScript({ Test-Path -PathType Leaf $_ })] [String] $FilePath,
[parameter(Mandatory=$False,Position=2)] [System.URI] $ResultURL
)
# CONST
$CODEPAGE = "iso-8859-1" # alternatives are ASCII, UTF-8
# We have a REST-Endpoint
$RESTURL = "https://my.portatour.net/a/api/ImportCustomers/"
@Schnouki
Schnouki / popcorntime-vpn.sh
Last active January 20, 2024 12:07
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
@spheromak
spheromak / attributes.rb
Last active August 29, 2015 14:01
Using attribute mode to drive dhcp_cookbook
default[:dhcp][:failover] = nil
default[:dhcp][:allows] = [ "booting", "bootp", "unknown-clients" ]
default[:dhcp][:hosts] = []
default[:dhcp][:groups] = []
default[:dhcp][:networks] = []
default[:dhcp][:interfaces] = []
default[:dhcp][:hosts_bag] = "dhcp_hosts"
default[:dhcp][:networks_bag] = "dhcp_networks"
#!/bin/bash
# ------------------------------------------------------------------------------
# Grid Engine Submit Parameters
# ------------------------------------------------------------------------------
#$ -N extract-split-tar-gz
#$ -S /bin/bash
#$ -pe smp 2-
#$ -l h_rt=120:00:00
#!/bin/bash
# Script to loop on local and remote branches, to delete all those which are
# already merged in master.
# Assumes "$USER" as your remote repository and "master" as your main branch.
# Careful if you use branches as tags!
#
# Inspired from http://devblog.springest.com/a-script-to-remove-old-git-branches
# Released under the WTFPL license version 2 http://sam.zoy.org/wtfpl/
# Copyright (c) 2012 Sanne Grinovero
# Copyright (c) 2012 Emmanuel Bernard - made remote repo parameterized
@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

@jboner
jboner / latency.txt
Last active May 12, 2024 07:29
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
@bhang
bhang / install_graphite_statsd_ubuntu_precise.sh
Created May 15, 2012 17:41
Install Graphite and statsd on Ubuntu 12.04 LTS (Precise Pangolin)
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
@vincentbernat
vincentbernat / harmony.xml
Created April 22, 2012 18:38
XBMC configuration with Logitech Harmony Remote and iMON
<keymap>
<global>
<keyboard>
<end>XBMC.ShutDown()</end>
<f1>XBMC.ActivateWindow(MusicLibrary)</f1>
<f2>XBMC.ActivateWindow(Videos,TvShowTitles)</f2>
<f3>XBMC.ActivateWindow(Videos,MovieTitles)</f3>
<f4>XBMC.ActivateWindow(Weather)</f4>
<f5>XBMC.PlayerControl(Partymode)</f5>
<two>JumpSMS2</two>