Skip to content

Instantly share code, notes, and snippets.

View pelletier's full-sized avatar

Thomas Pelletier pelletier

View GitHub Profile
"""
10268104 paths generated
4 function calls in 2.919 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.135 0.135 2.919 2.919 <string>:1(<module>)
1 0.000 0.000 2.784 2.784 test.py:12(sort_key)
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
@pelletier
pelletier / gist:1109290
Created July 27, 2011 12:46
Test website up (200 OK)
while true; do
string=`curl --silent -I "$1"`
if [[ $string == *"200 OK"* ]]
then
echo "ok";
else
echo "RED ALERT!";
fi
sleep 1
done
@pelletier
pelletier / gist:1113780
Created July 29, 2011 13:12
rc.local patch for auto DHCP on eht0 on Archlinux
--- rc.local.orig 2011-07-29 15:09:01.353309284 +0200
+++ /etc/rc.local 2011-07-29 15:08:19.689962672 +0200
@@ -3,3 +3,7 @@
# /etc/rc.local: Local multi-user startup script.
#
+# Enable DHCP at boot on eth0.
+# See https://wiki.archlinux.org/index.php/Network#DHCP_fails_at_boot
+dhcpcd -k eth0
+dhcpcd -nd eth0
@pelletier
pelletier / gist:1113784
Created July 29, 2011 13:14
/etc/rc.d/network patch for Vagrant with Archlinux. Makes `gateway` not required.
--- network.orig
+++ network
@@ -25,16 +25,16 @@
network_up() {
/usr/sbin/ip link set dev $interface up || return 1
if [[ $address ]]; then
- for var in netmask gateway; do
+ for var in netmask ; do
if [[ -z ${!var} ]]; then
@pelletier
pelletier / gist:1550311
Created January 2, 2012 11:09
AppleScript to send file to Kindle
on run {input, parameters}
tell application "Mail"
activate
end tell
tell application "Finder"
set visible of process "Mail" to false
end tell
tell application "Mail"
set newMessage to make outgoing message with properties {visible:true, content:"", subject:"convert"}
tell newMessage
@pelletier
pelletier / gist:2051430
Created March 16, 2012 17:47
Standalone Ruby script to take a screenshot and send the file to CloudApp under Linux
#!/usr/bin/env ruby
# Requirements:
# - X
# - Ruby
# - notify-send (libnotify)
# - XSel
# - Import
require 'date'

Keybase proof

I hereby claim:

  • I am pelletier on github.
  • I am pelletier (https://keybase.io/pelletier) on keybase.
  • I have a public key whose fingerprint is FD8F 938E EC93 5B80 E8BE F9C0 E944 7636 2D61 6DB9

To claim this, I am signing this object:

@pelletier
pelletier / doc.md
Last active April 5, 2021 19:11
Emacs forge Github store API token with Secret Service

Here is one way to use Magit's Forge feature with GitHub, storing the API token in Access Service.

Create token

https://github.com/settings/tokens

Permissions suggested by the official documentation: read:org repo user.

Install forge with secrets

@pelletier
pelletier / gist:2cf3053ecad136391f34d8a9facbb1a6
Last active May 16, 2021 11:26
TIL: dual-boot Linux+Windows, Intel Wi-Fi, and Fast Boot

Wi-Fi card not sometimes not detected when you boot Linux and have a Windows dual-boot?

https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi#about_dual-boot_with_windows_and_fast-boot_enabled

If you have a dual-boot machine with a recent version of Windows and start seeing problems during initialization of the WiFi device when booting Linux, the problem could be due to the “fast startup” feature on Windows.

With this feature enabled, Windows don't really shut down the entire system, but leaves things partially running so you can start the machine faster again. Try to disable this option, on Windows 10 it should be in “Control Panel→Hardware and Sound→Power Options→System Settings”. Select “Chooose what the power buttons do” to access the System Settings from the Power Options. Then disable the “Fast Startup” option in “Shutdown Settings”. This will cause Windows to fully shutdown and may solve the issue.

@pelletier
pelletier / benchmarking.md
Last active June 3, 2021 13:03
Benchmarking Go on AMD

While benchmarking https://github.com/pelletier/go-toml/tree/v2, I decided to play with CPU frequency scaling, to eliminate some noise in the benchmarks.

Running on the following:

goos: linux
goarch: amd64
cpu: AMD Ryzen 9 5950X 16-Core Processor
kernel: 5.12.8-300.fc34.x86_64