View gist:154cea4f94b30d1dc4d08dc5e626ccd8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Testy | |
def easy | |
puts "hi" | |
end | |
def hash(a:, b:, c:) | |
puts a | |
puts b |
View gist:06b84948783617cd345ed2c34ad5d8ee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 # use CircleCI 2.0 | |
jobs: # a collection of steps | |
build: # runs not using Workflows must have a `build` job as entry point | |
parallelism: 1 # run three instances of this job in parallel | |
# branches: | |
# only: | |
# - master | |
docker: # run the steps with Docker | |
- image: circleci/ruby:2.6.3 | |
environment: # environment variables for primary container |
View gist:9e7b297763901efbe6cf02b4cb13ae5f
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module QrCodeHelper | |
def qr_code(string, options={}) | |
base_size = options.fetch(:width, 200) | |
@qr_logo = options.fetch(:logo, "qr_code_logo.png") | |
@qr_logo_size = options.fetch(:logo_size, 48) | |
level = options.fetch(:level, :l) | |
@qr_data = RQRCode::QRCode.new(string, level: level).to_s.split("\n").collect(&:chars) | |
@qr_size = @qr_data.size |
View check_hashrate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import sys | |
import time | |
import datetime | |
import commands | |
import json | |
gDebugMode = 1 | |
gLogFile = "/home/ethos/gpu_hashrates.log" |
View monero_wallet.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem "money" | |
Money::Currency.register({ :priority => 1, :iso_code => "xmr", :iso_numeric => "846", :name => "Monero", :symbol => "XMR", :subunit => "", :subunit_to_unit => 1000000000000, :decimal_mark => ".", :thousands_separator => ""}) | |
class XMR | |
def self.new(amount); Money.new(amount, :xmr); end | |
def to_s; Money.new(amount, :xmr).format; end | |
end | |
class Monero::Wallet |
View sonoff.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Free to use. if you modify it, pls let me know, i might need your code aswell :-) | |
# github: krtschmr | |
# tim@krtschmr.de | |
# USAGE | |
# Straightforward | |
# Sonoff.on!("192.168.1.53") | |
# Sonoff.off!("192.168.1.53") |
View rails_friendship_and_blocklist.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
has_many :relations, class_name: "User::Relation" | |
has_many :friends,-> { where user_relations: {type: :friendship, state: :confirmed }}, through: :relations | |
has_many :pending_friendships,-> { where user_relations: {type: :friendship, state: :pending }}, through: :relations, source: :friend | |
has_many :blocked_users,-> { where user_relations: {type: :block }}, through: :relations, source: :friend | |
def request_frienship(friend) | |
raise Relation::ForeverAlone if friend == self | |
raise Relation::AlreadyConfirmed if friend_with?(friend) | |
raise Relation::AlreadyRequestedFriendship if pending_friend_request?(friend) |
View need_admin_approval.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage | |
# your model | |
# need_admin_approval fields: [:name, :description], if: :published?, unless: :trusted_user? | |
module NeedAdminApproval | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
View gist:8bdcb2a8f7c3d08ee7b7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_validation do | |
self.site_id = 1 | |
self.username=Devise.friendly_token.first(4) | |
self.slug = Devise.friendly_token.first(4) | |
self.email = "#{Devise.friendly_token.first(4)}@ficken.de" | |
generated_password = Devise.friendly_token.first(8) | |
self.password = generated_password | |
self.password_confirmation = generated_password | |
end |
View .rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "titlefy/version" | |
module Titlefy | |
# call from your controller (mostly ApplicationController) | |
def titlefy | |
send :include, InstanceMethods | |
end | |
module InstanceMethods |