Skip to content

Instantly share code, notes, and snippets.

View fiftin's full-sized avatar

Denis Gukov fiftin

View GitHub Profile
@fiftin
fiftin / add_background_to_spree_taxon.rb
Created September 14, 2015 04:11
Add image to model the example of Spree taxon model
class AddBackgroundToSpreeTaxons < ActiveRecord::Migration
def change
add_column :spree_taxons, :background_file_name, :string
add_column :spree_taxons, :background_content_type, :string
add_column :spree_taxons, :background_file_size, :integer
add_column :spree_taxons, :background_updated_at, :timestamp
end
end
@HGebhardt
HGebhardt / psql2sqlite.sed
Created April 28, 2015 12:49
Convert PostgreSQL data to SQLite
#! /bin/sed -f
# remove configuration settings
/^SET /d
# remove comments
/^--/d
# remove sequence values
/^SELECT pg_catalog.setval/d
@kennwhite
kennwhite / vpn_psk_bingo.md
Last active April 5, 2025 04:55
Most VPN Services are Terrible

Most VPN Services are Terrible

Short version: I strongly do not recommend using any of these providers. You are, of course, free to use whatever you like. My TL;DR advice: Roll your own and use Algo or Streisand. For messaging & voice, use Signal. For increased anonymity, use Tor for desktop (though recognize that doing so may actually put you at greater risk), and Onion Browser for mobile.

This mini-rant came on the heels of an interesting twitter discussion: https://twitter.com/kennwhite/status/591074055018582016

@fiftin
fiftin / HttpUploadImageTask.java
Last active September 13, 2015 18:21
Async uploading an image as file to the server from Android application
private class HttpUploadImageTask extends AsyncTask<String, Void, Boolean> {
final Bitmap imageBitmap;
public HttpUploadImageTask(final Bitmap imageBitmap) {
this.imageBitmap = imageBitmap;
}
@Override
protected Boolean doInBackground(String... urls) {
for (final String u : urls) {
try {
@sylr
sylr / postgres-9.5-sharding.sh
Last active June 11, 2019 21:23
Postgresql 9.5 sharding example
echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/dropdb -p 6432 -h /tmp -U postgres
echo master shard_{0,1,2,3} | xargs -n1 /usr/local/bin/createdb -p 6432 -h /tmp -U postgres
for a in {0..3}; do
echo "
CREATE TABLE users (id serial PRIMARY KEY, username TEXT NOT NULL);
ALTER SEQUENCE users_id_seq INCREMENT BY 4 RESTART WITH $a;
" | /usr/local/bin/psql -p 6432 -h /tmp -U postgres -d shard_$a;
done
@divineforest
divineforest / gateway.rb
Created February 4, 2015 13:27
Spree example gateway
module Spree
class Gateway::NewGateway < Gateway
preference :login, :string
preference :password, :string
preference :signature, :string
preference :currency_code, :string
def provider_class
ActiveMerchant::Billing::New
end
@kany
kany / sendmail_setup.md
Last active January 27, 2025 11:55
Setup SENDMAIL on Mac OSX Yosemite
@andrest
andrest / gist:a64649f128af1bd368ee
Created December 15, 2014 09:44
checkout_controller_decorator.rb
Spree::CheckoutController.class_eval do
def before_address
# If the user has a default address, a callback takes care of setting
# that; but if he doesn't, we need to build an empty one here.
# Regardless of checkout steps, build a shipping address
@order.bill_address ||= Spree::Address.build_default
@order.ship_address ||= Spree::Address.build_default
end
@adamwalz
adamwalz / vpn_shared_secret_decoder.py
Created November 20, 2014 22:50
VPN Shared Secret decoder for networkConnect files
#!/usr/bin/python
# Decoder for the ExportedSharedSecret values stored in .networkConnect files
# Tested with .networkConnect files created in Mac OS X 10.10
#
# Author: Martin Rakhmanov, http://jimmers.info
#
# Example invocation and output:
#
# python vpn_shared_secret_decoder.py TLthF+e88vwmAYhK
@danbarua
danbarua / PartialFileResponse.cs
Created November 10, 2014 08:22
206 Partial Content responses for Nancy
namespace Infrastructure
{
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using Nancy;
using Util;