Skip to content

Instantly share code, notes, and snippets.

View GregPK's full-sized avatar

Grzegorz Kaczorek GregPK

View GitHub Profile
@GregPK
GregPK / qStartEnd.sql
Last active December 10, 2015 23:28
Two functions that return the date of the start and end of the quarter of which the given date is in. (+some "unit tests").
DELIMITER $$
/** qStart (DATE date)
* Get the date of the start of a quarter given a date in that quarter.
*/
DROP FUNCTION IF EXISTS `qStart`$$
CREATE FUNCTION `qStart`(d DATE) RETURNS DATE
DETERMINISTIC
BEGIN
RETURN d - INTERVAL MOD(MONTH(d)-1,3) MONTH - INTERVAL DAY(d)-1 DAY;
@GregPK
GregPK / loadmon.sh
Created January 29, 2013 16:10
Simple load monitor for a linux machine. Gets content of /proc/avgload every 5 sec and a timestamp. usage: `./loadmon > loadmon.csv`
#!/bin/bash
while [ true ]; do
echo -n `date '+%Y-%m-%d_%H:%M:%S'` ; echo -n ' '; awk '{print date $1,$2,$3}' /proc/loadavg
sleep 5
done
@GregPK
GregPK / Regex-Crossword-helper.js
Last active December 20, 2015 06:49
A helper for http://regexcrossword.com. It helps identify which patterns are not met in a non-boolean fashion. It's a spoiler, so use sparringly. Also, please note that not all situations are accounted for (empty spaces, greedy vs non-greedy matching).
window.CrossCrutch = {}
window.CrossCrutch.check = function() {
var messages = [];
$(".puzzle table tbody tr").each(function (i,e) {
var $row = $(e);
var $cols = $row.find("th,td");
var $rowHeader = $cols.filter("th");
var $other = $cols.filter("td");
@GregPK
GregPK / regex-crossword-shift.js
Created August 8, 2013 11:17
Make the Regex descriptors at the top less head-turningish.
$(".crossword table thead span, .crossword table tfoot span").css({
"transform": "translate(26px, 15px) rotate(-25deg)",
"text-align": "left"
});
@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
@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 / 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 / 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 / gist:5eadbae83bca4f24add6
Created October 29, 2014 21:52
Stepmania crash log
StepMania v5.0 beta 4a
Compiled 20141029 @ 10:32:04 PM CET (UTC+01:00) (build 0)
Log starting 2014-10-29 22:50:53
Xlib: extension "RANDR" missing on display ":0".
Loading window: gtk
OS: Linux ver 030500
Crash backtrace component: x86 custom backtrace
Crash lookup component: dladdr
Crash demangle component: cxa_demangle
Runtime library: glibc 2.15