Skip to content

Instantly share code, notes, and snippets.

@bithavoc
bithavoc / eureka_swift_3:composable_search_row.swift
Last active April 23, 2024 13:32
Eureka Swift 3 Composable Search Row
open class _ComposableSearchablePushRow<T: Equatable, Cell: CellType> : TableSelectorRow<Cell, ComposableSearchableViewController<T>> where Cell: BaseCell, Cell: TypedCellType, Cell.Value == ComposableSearchableItem<T>, T: SearchableItem, T: CustomStringConvertible {
public required init(tag: String?) {
super.init(tag: tag)
onCreateControllerCallback = { [weak self] _ in
let controller = ComposableSearchableViewController<T>()
controller.searchPlaceholder = self?.searchPlaceholder
return controller
}
@bithavoc
bithavoc / add_multilang_hstore_gem_to_gemfile.sh
Last active December 12, 2019 06:41
Using multilang-hstore in Rails 4
# add the gem to your Gemfile
gem 'multilang-hstore', '~> 1.0.0'
# execute bundle install
@bithavoc
bithavoc / nodejs_asymm_crypto_sample.js
Created October 20, 2011 02:17
Asymmetric Encryption Sample in Node.js: Encrypt and Decrypt using Password as a key(SECRET_KEY) / Triple-DES
/*
Asymmetric Encryption Sample in Node.js: Encrypt and Decrypt using Password as a key(SECRET_KEY)
Algorithm: des-ede3-cbc (Three key Triple-DES EDE in CBC mode)
johan@firebase.co
@thepumpkin
*/
var assert = require('assert')
var crypto = require('crypto')
var Buffer = require('buffer').Buffer
@bithavoc
bithavoc / postgres-notify-trigger.sql
Last active February 2, 2019 09:31
I used this trigger to notify table changes via NOTIFY (migrating off RethinkDB)
CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$
DECLARE
channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes');
BEGIN
IF TG_OP = 'INSERT' THEN
PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}');
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}');
@bithavoc
bithavoc / asset_helper.rb
Created October 23, 2017 01:42 — forked from jeremyruppel/asset_helper.rb
Inline asset helpers for middleman.
module AssetHelper
##
# Renders a stylesheet asset inline.
def inline_stylesheet( name )
content_tag :style do
sprockets[ "#{name}.css" ].to_s
end
end
@bithavoc
bithavoc / challenge.sh
Created January 31, 2017 04:07
Letsencrypt manual DNS challenge via TXT records
sudo certbot certonly -d vault.reeactr.com --manual --preferred-challenges dns-01
@bithavoc
bithavoc / dparsingjsonvalueretain.d
Last active October 21, 2016 13:15
Demo of Parsing objects using instances of JSONValue
/*
* http://johan.heapsource.com
*/
import std.stdio;
import std.json;
JSONValue doc;
void main() {
@bithavoc
bithavoc / azure_env_detection.cs
Created January 12, 2014 21:22
determinate if running in azure fabric, emulated or not
using Microsoft.WindowsAzure.ServiceRuntime; // Microsoft.WindowsAzure.ServiceRuntime.dll
...
if (RoleEnvironment.IsAvailable) {
// running inside Azure Fabric
if(RoleEnvironment.IsEmulated) {
// Fabric is running in Emulator
@bithavoc
bithavoc / events_example.d
Created December 25, 2013 16:09
Example of Events.d, the first Event Model for D programming language
//
// http://blog.heapsource.com/post/71111508527/events-d
//
import std.stdio;
import std.string;
import events;
void main() {
auto event = new EventList!(string, int);
@bithavoc
bithavoc / http-parser-example.d
Created December 25, 2013 16:01
Example of joyent/http-parser bindings for D programming language
//
// http-parser.d example
// http://blog.heapsource.com/post/70495154255/announcing-http-parser-d
//
import std.stdio;
import http.parser.core;
void main() {
"http-parser.d in action with fixed-size Http Message Body".writeln;