Skip to content

Instantly share code, notes, and snippets.

View hrp's full-sized avatar

Hiten Parmar hrp

View GitHub Profile
@hrp
hrp / swizzin-proxmox.md
Last active August 12, 2023 20:50
Swizzin install with Proxmox

Swizzin install with Proxmox

Unprivileged container with local bind mount.

  1. Create container with Ubuntu 22.04 LTS
  2. Install Swizzin with script. Note user created.
  3. On Proxmox host, create group for container-data for unused group id (used 101001)
addgroup --gid 101001 container-data
#!/usr/bin/ruby
require 'benchmark'
puts "Running Ruby #{RUBY_VERSION}"
ary = []
200.times {
ary << {:bar => Time.at(rand * Time.now.to_i)}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hrp
hrp / kill-postgres
Created December 10, 2015 18:40
Force kill postgres on OS X El Capitan
pg_ctl -D /usr/local/var/postgres -m immediate stop
@hrp
hrp / stack_qa
Created February 10, 2015 22:57
Stackosaurus Rex
# Design a data structure supporing the following:
# 1) Push an element
# 2) Pop an element
# 3) Find Minimum in the data structure
# Push(12)
# 12
# Min() ==> 12
/* Prototype JavaScript framework, version 1.7
* (c) 2005-2010 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
*--------------------------------------------------------------------------*/
var Prototype = {
@hrp
hrp / emojibomb.rb
Last active August 29, 2015 13:55 — forked from cobyism/emojibomb.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
# Run `emojibomb` to get three emoji.
# Run `emojibomb N`, where `N` is a positive integer to get N emoji.
doc = Nokogiri::HTML(open("http://www.emoji-cheat-sheet.com/"))
emoji = doc.css('.name')
@hrp
hrp / acts-as-taggable-speed.rb
Last active January 3, 2016 03:59
acts-as-taggable-on speed hack
module ActsAsTaggableOn
mattr_accessor :ignore_case_for_mysql
@@ignore_case_for_mysql = false
class Tag
class << self
def named_any_with_ignore_case(list)
if ActsAsTaggableOn.ignore_case_for_mysql
where(list.map { |tag| sanitize_sql(["name = ?", tag.to_s.mb_chars.downcase]) }.join(" OR "))
else
@hrp
hrp / no-ascii.rb
Created December 28, 2013 01:36
Dump non-ascii benchmark
# encoding: utf-8
require 'benchmark'
require 'iconv'
class String
def remove_nonascii(replacement='')
n=self.split("")
self.slice!(0..self.size)