Skip to content

Instantly share code, notes, and snippets.

View GregPK's full-sized avatar

Grzegorz Kaczorek GregPK

View GitHub Profile
@GregPK
GregPK / loadtempmon.sh
Created September 26, 2013 08:28
Simple load and temperature monitor for my HTPC box. Originally used to measure efficiency of GPU drivers (integrated into the CPU) and the noise they make (fan speed)
#!/bin/bash
while [ true ]; do
echo -n `date '+%Y-%m-%d_%H:%M:%S'` ;
echo -n ' ';
awk '{print $1,$2,$3}' /proc/loadavg | tr -d '\n';
echo -n ' ';
sensors | grep fan1 | tr -d '\n' | awk '{printf $2}';
echo -n ' ';
sensors | grep temp1 -m 1 | tr -d '\n' | awk '{gsub(/[C°\+\^]/,"")}; {printf $2}';
echo -n ' ';
# A Guardfile for use with nodeschool (http://nodeschool.io/)
# (part 1 - learnyounode)
# verify solution when any js.file changed
guard :shell do
watch(/(.*).js/) {|m| `learnyounode verify #{m[0]}` }
end
@GregPK
GregPK / pulse-audio-switch.rb
Created January 16, 2017 16:17
pulse-audio-switch.rb
#!/usr/bin/env ruby
sink_output = `pacmd list-sinks`
sinks_index_lines = sink_output.each_line.select{|line| line =~ /index/}
sinks_indexes = sinks_index_lines.map{|index_line| Integer(index_line.strip.gsub(/[^\d]/,'')) }
# optional - for more descriptive notification message
card_names = sink_output.each_line.select{|line| line =~ /alsa.card_name/}.map{ |l| l.gsub(/.+ = "(.+)"/,'\1').strip }
card_names_dict = Hash[sinks_indexes.zip(card_names)]
@GregPK
GregPK / past_dweller.rb
Created November 22, 2018 12:50
past_dweller
require 'date'
MONTHS = 18
CMD = 'git log --pretty="%an %ae%n%cn %ce" -- graphql_api | sort | uniq | wc -l'
# cloc . | grep Ruby
results = []
MONTHS.times do |i|
date = (DateTime.now - (i*30)).strftime("%Y-%m-%d")
`git checkout \`git rev-list -n 1 --before="#{date} 00:00" master\` > /dev/null 2>&1`
@GregPK
GregPK / hyper.txt
Last active July 21, 2019 16:30
xef | ts (Meta vs Super keys)
Jul 21 18:23:10 KeyPress event, serial 37, synthetic NO, window 0xa000001,
Jul 21 18:23:10 root 0x1f5, subw 0x0, time 11238404, (103,-1), root:(964,456),
Jul 21 18:23:10 state 0x10, keycode 133 (keysym 0xffed, Hyper_L), same_screen YES,
Jul 21 18:23:10 XLookupString gives 0 bytes:
Jul 21 18:23:10 XmbLookupString gives 0 bytes:
Jul 21 18:23:10 XFilterEvent returns: False
Jul 21 18:23:11
Jul 21 18:23:11 KeyRelease event, serial 37, synthetic NO, window 0xa000001,
Jul 21 18:23:11 root 0x1f5, subw 0x0, time 11238752, (103,-1), root:(964,456),
Jul 21 18:23:11 state 0x50, keycode 133 (keysym 0xffed, Hyper_L), same_screen YES,
@GregPK
GregPK / tn.rb
Created August 4, 2019 12:31
tn - a taskwarrior script to show my my most important tasks
#!/usr/bin/ruby
require 'time'
filters = []
configs = []
hour = Time.now.hour
def is_weekend?
t = Time.now
t.saturday? || t.sunday?
@GregPK
GregPK / FileUploadComponent.jsx
Created May 22, 2017 07:32 — forked from github0013/FileUploadComponent.jsx
how to upload files using graphql + apollo client
class FileUploadComponent extends Component{
upload(){
this.props.mutate({
variables: {
id,
avatar: this.inputFile.files[0] //this is how you send file
}
}).
then(({data}) => {
console.log(data)