Skip to content

Instantly share code, notes, and snippets.

View b1nary's full-sized avatar

Roman Pramberger b1nary

View GitHub Profile
@b1nary
b1nary / bash.sh
Created July 19, 2016 08:49
Tweee.co
curl --data "text=Hi there&key=<%= current_api_key %>&media[]=https://example.com/image1.jpg&media[]=https://example.com/image2.jpg" https://tweee.co/api/tweet
<%= form_tag "https://#{Rails.env.development? ? "url.com" : "other.ch"}/@@search", method: :get, id: "quick-search", role: "search" do %>
<div class="input-group">
<input type="hidden" name="facet" value="true">
<input type="hidden" name="fq" value='site_area:"Kantonsratsgeschäfte"'>
<input type="hidden" name="facet.field" value="object_type">
<input type="hidden" name="facet.field" value="topics">
<%= text_field_tag :SearchableText, "", placeholder: t("navigation.search.placeholder"), class: "form-control" %>
<span class="input-group-btn">
<button class="btn btn-secondary" id="search_submit" type="submit">
<span class="glyphicon glyphicon-search"></span>
#!/usr/bin/env ruby
require 'sinatra'
require 'json'
post '/hook' do
mention = JSON.parse(request.body.read)
# ...
content_type :json
@b1nary
b1nary / test_helper.rb
Created May 24, 2016 13:36
Capybara + Select2 v4 + Ajax search
module Select2Helper
def select2 value, **options
first("#select2-#{options[:from]}-container").click
find('.select2-search__field').set('National')
find(".select2-results__option", text: value).click
end
end
@b1nary
b1nary / howto.md
Created April 29, 2016 07:38
Stick to Postgres 9.4 (oder version) on OSX

I am sure i'll run into this again, so i document the Process.

I need a older version because our servers still use 9.4 and 9.5 dumps from rails generate a non valid SQL structure.

Install older Postgres version:

  1. http://postgresapp.com/
  2. export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

Make it work with Rails

@b1nary
b1nary / _.md
Last active April 2, 2016 00:22
Unicorn Robin "ad"block

Unicorn Robin "ad"block

Use Tampermonkey for Chrome or Greasemonkey for Firefox

  • Blocks most vote spam
  • Double click usernames to block them in future
  • no "setInterval" so no flicker or lag!

Click [Raw] (right below from here) to install.

@b1nary
b1nary / _.md
Last active April 1, 2016 20:39
HAIL PAGGAUNT

HAIL PAGGAUNT

  • Grow automatically
  • Have some fancy stats
  • Chat history on reload
  • Autoscroll (that was broken for me, maybe you want to remove it see the comments)

Beware its very lazy and bad done, but it does its job.

screenshot

@b1nary
b1nary / _.md
Last active February 11, 2016 14:44
Flippa Ending Soon Robot for Slack

FlippSlacka

Installation:

I assume you run Linux and have ruby installed.

  • wget https://gist.githubusercontent.com/b1nary/69f7a6ec32967e363c9b/raw/flippslacka.rb
  • chmod +x flippslacka.rb
  • crontab -e
  • Add: 30 9 * * * ruby /path/to/flippslacka.rb
@b1nary
b1nary / style.css
Created November 4, 2015 16:05
Collecting User Browser Display dimensions with CSS.
@media screen and (max-width: 1px){ #dummy { background:url(/endpoint/width/1); } }
@media screen and (max-width: 2px){ #dummy { background:url(/endpoint/width/2); } }
@media screen and (max-width: 3px){ #dummy { background:url(/endpoint/width/3); } }
@media screen and (max-width: 4px){ #dummy { background:url(/endpoint/width/4); } }
/* More */
@media screen and (max-width: 50px){ #dummy { background:url(/endpoint/width/50); } }
/* More */
@media screen and (max-width: 1280px){ #dummy { background:url(/endpoint/width/1280); } }
/* and then repeat same for height. Note that resizing the browser windows might creates additional requests */
@b1nary
b1nary / math.rb
Last active October 15, 2015 12:40
LOAN?
#!/usr/bin/env ruby
INPUT = 1.0
RATE = 0.000355
DAYS = [1, 2, 3, 7, 14, 30, 60, 90, 180, 364]
DAYS.each do |days|
out = INPUT
days.times do |i|
out += out*RATE