Skip to content

Instantly share code, notes, and snippets.

@mkrogh
mkrogh / such_miner.js
Last active May 3, 2022 19:22
dogeminer.se, got bored clicking.
//go to Settings -> Toggle click effects
var muchClick = function(amount){return function(){var $mine = $("#miner"); for(var i = 0; i < amount; i++){$mine.trigger("mousedown");}}};
var veryTimer = setInterval(muchClick(100),150);
//clearInterval(veryTimer);
@mkrogh
mkrogh / filter.js
Created March 6, 2013 08:36
Simple JS filter function for searching in tables. Done in an MVC fashion.
(function($){
var makeObservable = function() {
var observers = [];
var addObserver = function(observer) {
observers.push(observer);
};
var removeObserver = function(observer){
var idx = observers.indexOf(observer);
if(idx != -1) observers.splice(idx, 1);
def create
@admin = Admin.find_by_provider_and_uid(auth["provider"], auth["uid"])
if @admin and @admin.approved
session[:user_id] = @admin.id
flash[:success] = "Hej #{@admin.name} du er nu logget ind"
redirect_to session[:return_to] || manage_golds_path
else
unless @admin.present?
new_admin = Admin.create(:name => auth["info"]["name"], :provider => auth["provider"], :uid => auth["uid"])
BankAccountMailer.admin_created(new_admin).deliver
@mkrogh
mkrogh / fileless_file.rb
Created March 3, 2012 00:51
Carrierwave proccess zipfile contents
#A nice little carrierwave IO faker class
class FilelessFile < StringIO
attr_accessor :original_filename
end
@mkrogh
mkrogh / included.js
Created January 18, 2012 18:20
Titanium ImageView path problem
// located in: /js/include.js
// this works just fine:
// The leftImage is shown
var table = Ti.UI.createTableView({
data: [{leftImage: '/icons/test.png', "title": "test"}]
});
//This does not work:
// neither does image: '../icons/test.png'"
@mkrogh
mkrogh / ruby-1.8.7.rb
Created January 12, 2012 21:32
rubyzip + open-uri (1.8.7 and 1.9.2)
require "open-uri"
require "zip/zip"
img_url = "http://jquery.com/demo/thickbox/images/plant4.jpg"
img_name = "plant4.jpg"
#this works in 1.8.7, but not in 1.9.2:
Zip::ZipFile.open("test.zip", Zip::ZipFile::CREATE) do |zipfile|
img = open(img_url)
zipfile.add(img_name, img.path)
@mkrogh
mkrogh / gist:1220514
Created September 15, 2011 21:22
Markdown syntax oddity

One would suspect that the following markdown code would yield first an un-ordered list followed by an ordered list.

  • An item
  • Another item
  • Just an extra item to make it interesting
  1. First you would expect this ordered list item to be a separate list due to the double linebreak
  2. Secondly you would not expect the above item to be wrapped in a paragraph tag.
from chinchilla import *
import time
GREEN = "\x1b[32m"
RED = "\x1b[31m"
ORANGE = "\x1b[33m"
RESET = "\x1b[0m"
success,error = 0,0
def check_link(txt,content):
global success, error

NORDUnet NI 2.0 router hardware model

// Create nodes
CREATE (router1:Physical:Router{name:'Router1', serial_number:'1'}),
       (midplane:Physical:Module{name:'Midplane', model_number:'CHAS-1'}),
       (fpmDisplay:Physical:Module{name:'FPM Display', model_number:'CRAFT-MX80-S'}),
@mkrogh
mkrogh / aliases
Created June 10, 2015 12:59
A collection of useful bash aliases.
# git
alias gits='git status -uno' #don't show untracked files
# OpenSSL
function ssltest() {
local SN=${2:-1}
echo QUIT | openssl s_client -showcerts -connect $1:443 -servername $SN | grep -A 1 "s:/"
}
alias ssltest=ssltest