Skip to content

Instantly share code, notes, and snippets.

View skateman's full-sized avatar

Halász Dávid skateman

View GitHub Profile
@skateman
skateman / capture.js
Created May 7, 2015 11:49
PhantomJS Screen Capture
/*
* Usage: phantomjs capture.js [width] [height] [url] [output]
*/
var system = require('system');
var args = system.args;
if (args.length === 5) {
var width = args[1];
var height = args[2];
@skateman
skateman / falugiri.rb
Created June 7, 2015 10:40
Slovakian settlement DB scraper
require 'json'
require 'open-uri'
require 'nokogiri'
require 'ruby-progressbar'
BASEURL = "http://adatbank.sk/telepulesek/szlovakia-telepuleseinek-listaja"
db = []
doc = Nokogiri::HTML(open(BASEURL))
@skateman
skateman / fulltext_searchable.rb
Created August 23, 2015 14:48
ElasticSearch integration to ActiveRecord
module FulltextSearchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
end
module ClassMethods
# Use this method to specify which columns you want to index
@skateman
skateman / pseudo_columns.rb
Created August 23, 2015 14:53
PseudoColumns can mask columns with default values, useful when joining tables in ActiveRecord
module PseudoColumns
extend ActiveSupport::Concern
module ClassMethods
# Specify the columns in {name => default_value} format
def pseudo_columns(columns = {})
columns.each do |k, v|
define_method(k) do
attributes.fetch(__method__.to_s, v)
end
@skateman
skateman / separate_worker.rb
Created April 19, 2016 08:03
Snippet to start a MiqWorker separately
MiqWebsocketWorker.delete_all
require_relative 'config/environment'
class MiqWebsocketWorker::Runner
def heartbeat
end
end
row = MiqWebsocketWorker.create_worker_record
guid = row.guid
@skateman
skateman / gifcast
Last active December 13, 2017 13:43
#!/bin/sh
# gifcast - easily create gif screencasts from a selected area
#
# The first run lets you select a rectangle and starts recording while the second run stops the recording.
# Tested on Fedora 24 with GNOME
# Dependencies: xrectsel, byzanz, convert (ImageMagick)
FILE="/run/user/${UID}/$(basename $0).pid"
package semaphore
import "sync"
type Semaphore struct {
Channel chan uint
Mutex sync.Mutex
}
func New(size uint) *Semaphore {
@skateman
skateman / agents.rb
Last active February 10, 2017 09:49
List of Czechoslovak agents operating between 1975-1989 in Western-Slovakia
require 'json'
require 'nokogiri'
require 'open-uri'
BASE = 'http://www.upn.gov.sk'.freeze
url = "#{BASE}/utvary-stb-a-ps-na-slovensku/zoznam-osob.php?pismeno=".freeze
agents = []
# Separate page for each letter
#!/bin/env ruby
# Script to approve a GitHub PR from the command line
#
# Usage: ./approve.rb <repo> <PR>
# For auth configuration see: https://github.com/octokit/octokit.rb#using-a-netrc-file
require 'octokit'
require 'netrc'
$('#submissionInstructionsHeader').remove();
$('#FwkErrorBeanId').remove();
$('#PreHeaderLayout').remove();
$('#DefaultFormName > table').remove();
$('#LLAOutput').remove();
$('#ConfirmationPgStackLayout tbody').children[1].remove();