Skip to content

Instantly share code, notes, and snippets.

View GregPK's full-sized avatar

Grzegorz Kaczorek GregPK

View GitHub Profile
@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)
@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 / 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 / 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 / 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)]
# 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 / 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 ' ';
@GregPK
GregPK / CopyAsanaProjects.php
Last active December 22, 2015 08:49 — forked from AWeg/CopyAsanaTasks.php
This utility class allows you to copy projects from one workspace in Asana to another. Shortcomings: * any tasks that have been set up as recurring will not preserve that setting (a limitation of the Asana API)
<?php
class CopyAsanaWorkspace
{
public $apiKey; /// Get it from http://app.asana.com/-/account_api
public $indentationLevel = 0;
public $verbose = true;
private $projectFields = array('name','color','notes');
@GregPK
GregPK / tag-class-generator.css.sass
Created August 9, 2013 10:10
Generates #{n} classes in the form of "tag{#n}" where the class has a distinct background color and a dynamically calculated text color complimenting the background for readability. This can be used to generate a random class for a tag. Three color set included (generated at http://tools.medialab.sciences-po.fr/iwanthue/)
$tag_colors_intense: #0563BB #C96408 #C70078 #10998F #649218 #C85CEF #CC8A90 #244D6F #9EA9CB #4D286B #EA9B5E #F95BC8 #9B0046 #783DB5 #72B2F7
$tag_colors_green: #49B51B #6E8163 #B0FBB0 #5D821A #2AFD5A #2FA87E #90AB66 #23BC58 #92EB61 #7EEC8A #8ABE2B #8CB68D #6BDF23 #1AC67F #8CEBB7
$tag_colors_blue: #4CE68D #63825C #7AE42C #5C9020 #D2EE95 #54B47A #AADB4B #AED7A3 #4BB33A #398D42 #65E55B #9DBB6D #60813D #A2D66A #88E593
$tag_colors: $tag_colors_intense
@mixin tag($n)
$color: nth($tag_colors, $n)
background: $color
@if lightness($color) > 60
color: #111
@GregPK
GregPK / tag_class_helper.rb
Created August 9, 2013 10:05
Just a simple rails helper for getting a CSS class in the form `tag{n}`.
def tag_class(tag,max_number=15)
srand(tag.id)
tag_id = rand(1..max_number)
"tag#{tag_id}"
end