Skip to content

Instantly share code, notes, and snippets.

@kirqe
kirqe / nyancatnpc.gif
Last active November 17, 2021 18:11
Nyan Cat
nyancatnpc.gif
@kirqe
kirqe / nyancat.gif
Created April 24, 2021 16:43
Nyan Cat
nyancat.gif
@kirqe
kirqe / kube-docker-registry.yaml
Created March 9, 2021 15:02
tl;dr k3s private docker registry
sudo apt install apache2-utils
htpasswd -Bc registry.password registry
kubectl create namespace cert-manager
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.1.1/cert-manager.yaml
kubectl apply -f kube-docker-registry.yaml
kubectl create secret docker-registry regcred \
@kirqe
kirqe / gist:8b968ade687cd527d691598288ebeaaf
Created August 26, 2020 19:34 — forked from jamiehodge/gist:1327195
Warden and Sinatra example
require 'sinatra/base'
require 'rack/flash'
require 'warden'
require 'slim'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table :users do
primary_key :id
@kirqe
kirqe / RowView.swift
Created October 15, 2019 02:59
Use color for selected NSTableRowView
import Cocoa
class ThreadsListItemRowView: NSTableRowView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
if isSelected == true {
NSColor(hexFromString: "#ff9800").set()
dirtyRect.fill()
}
def m(n)
seq = (0..n/2).to_a
res = []
seq.each do |e|
r = (0..e).to_a
r << r.last while r.length < seq.length
res << r + r.reverse.drop(1)
end
res + res.reverse.drop(1)
end
@kirqe
kirqe / ruby_fib.rb
Last active June 21, 2018 15:38
ruby fibonacci sequence?
def fib_seq(n)
one, two, index, sequence = 0, 1, 0, []
while index < n
one, two = two, (one + two)
sequence << two
index = index + 1
end
sequence
end
@kirqe
kirqe / Gemfile
Created April 19, 2018 23:36
simple api pagination
gem 'jbuilder', '~> 2.5'
gem 'kaminari'
# subscription/payment controller
def execute
payment = PayPal::SDK::REST::Payment.find(params[:paymentId])
if payment.execute(payer_id: params[:PayerID])
current_user.subscription.prolong_for(cookies.signed[:duration])
clear_stash
redirect_to root_path, notice: "Subscribed successfully"
else
redirect_to root_path, error: "Something went wrong"