Skip to content

Instantly share code, notes, and snippets.

View kirichkov's full-sized avatar

Georgi Kirichkov kirichkov

View GitHub Profile
@kirichkov
kirichkov / gist:3600870
Created September 2, 2012 15:58
Generate html for all files in a directory
ls -1 | while read filename; do echo "<li><a href=\"/uploads/$filename\" target=\"_blank\">"; echo `basename $filename .pdf` | sed 's/_/ /g'; echo "</a></li>"; done
@kirichkov
kirichkov / gist:3600875
Created September 2, 2012 15:59
Reverse a text file's lines - the first line becoming the last
cat -n FILE | sort -nr | cut -c 8- > NEWFILE
@kirichkov
kirichkov / Custom filename based on current date
Last active October 11, 2015 07:47
Custom date format, suitable for use in file names
date +"%y-%m-%d_%H-%M"
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 pathfinder (10.20.31.1) 1.639 ms 1.032 ms 0.794 ms
2 asr-1001.nbis.net (87.120.131.7) 1.322 ms 1.847 ms 1.848 ms
3 46.107.27.133 (46.107.27.133) 8.780 ms 8.980 ms 8.756 ms
4 81.183.0.79 (81.183.0.79) 22.275 ms
81.183.0.73 (81.183.0.73) 22.061 ms 22.394 ms
5 30gigabitethernet4-3.core1.fra1.he.net (80.81.192.172) 41.999 ms 49.115 ms 41.045 ms
6 10gigabitethernet2-2.core1.par2.he.net (72.52.92.26) 62.535 ms 58.886 ms
10gigabitethernet1-4.core1.par2.he.net (184.105.213.162) 59.168 ms
7 10gigabitethernet7-1.core1.ash1.he.net (184.105.213.93) 137.223 ms 137.235 ms 141.452 ms
@kirichkov
kirichkov / throttle.sh
Created April 18, 2013 08:45
# Throttle all incoming and outgoing data to port 3000 at 48KB/s
# Throttle all incoming and outgoing data to port 3000 at 48KB/s
sudo ipfw pipe 1 config bw 48KByte/s
sudo ipfw add 101 pipe 1 src-port 3000
sudo ipfw add 102 pipe 1 dst-port 3000
# Delete
sudo ipfw delete 101 pipe 1
sudo ipfw delete 102 pipe 1
@kirichkov
kirichkov / php_scan.sh
Last active December 17, 2015 09:58
Scan all PHP scripts in a directory for most-common web-shells
grep -RPl --include=*.{php,txt,asp} "(passthru|shell_exec|system|phpinfo|base64_decode|chmod|mkdir|fopen|fclose|readfile) *\(" .
1/1 - ON
hardware: 433gpio
pulse: 3
rawlen: 50
binlen: 12
pulselen: 391
Raw code:
391 1173 391 1173 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 1173 391 1173 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 1173 1173 391 391 13294
Binary code:
@kirichkov
kirichkov / comfortable_mexican_sofa.rb
Created August 7, 2014 20:25
Comfortable Mexican Sofa v 1.12 fixture export workaround
# Add this content at the very end of config/initializers/comfortable_mexican_sofa.rb
# Monkey patch the fixture exporter
module ComfortableMexicanSofa::Fixture::File
class Exporter < ComfortableMexicanSofa::Fixture::Exporter
def export!
prepare_folder!(self.path)
self.site.files.each do |file|
file_path = File.join(self.path, file.file_file_name)
block = file.block
@kirichkov
kirichkov / appdaemon.cfg
Created August 12, 2017 21:24
Preserving Manual Alarm state in HASS through AppDaemon v1.
# This is to be added after the standard AppDaemon configuration
[switch_reset]
module = switch_reset
class = SwitchReset
# Choose where to store the states across restarts
file = /home/hass/preserved_states
delay = 0
# Change to whatever name you've given the alarm panel, you can experiment adding extra entities and see whether they work. I've tested successfully with switches and generic_thermostat
additional_entities = alarm_control_panel.alarm