Skip to content

Instantly share code, notes, and snippets.

View hakanensari's full-sized avatar

Hakan Ensari hakanensari

  • Amsterdam
  • 02:47 (UTC +02:00)
View GitHub Profile
@hakanensari
hakanensari / gist:13515ba153e34c3d7474e42d265a62fb
Last active November 10, 2023 15:00
don't drop packets in country.is
echo "net.netfilter.nf_conntrack_max=524288" > /etc/sysctl.d/10-conntrack-max.conf
echo "net.netfilter.nf_conntrack_tcp_timeout_established=300" > /etc/sysctl.d/10-conntrack-tcp-timeout-established.conf
echo "nf_conntrack" >> /etc/modules
@hakanensari
hakanensari / multi.rb
Created January 28, 2011 12:50
Attach Net:HTTP requests to multiple local IPs
require 'net/http'
ips = `ifconfig | awk '/inet addr:[0-9]/{print $2;}' | grep -oE '([0-9.]{7,})'`.
split("\n").
select { |ip| ip.match(/\./) && !ip.match(/^127/) }
def attach_to(ip)
TCPSocket.instance_eval do
(class << self; self; end).instance_eval do
alias_method :original_open, :open
@hakanensari
hakanensari / 01-revenge-and-self-realization.md
Last active January 19, 2023 16:41
A short story by ChatGPT

The woman sat at her desk, pen in hand, a blank sheet of paper before her. She stared at the page, her mind awhirl with thoughts and plans, as she began to write the names of those she intended to kill.

First on the list was a man, a cruel and ruthless dictator who had caused countless deaths and suffering. She had spent years researching his every move, studying his weaknesses, and planning her attack.

Next, she wrote the name of a hairdresser, a woman who had once cut her hair too short and refused to fix it. The woman had never forgotten the slight, and had long dreamed of seeking revenge.

Finally, she wrote the name of a software developer, a man who had created a program that had cost her her job. She had spent months learning to code, mastering the intricacies of the software, and devising a way to shut it down and ruin his career.

As she finished writing the names, she felt a sense of satisfaction and power, knowing that her victims would soon meet their end at her hands. But as she looked at the l

@hakanensari
hakanensari / assyrian-vet-billiard-obsession.md
Last active January 18, 2023 19:58
A short story by ChatGPT

Once there was an Assyrian veterinarian named Peter. He was an expert in his field, but he had a peculiar obsession - collecting billiard balls.

He had started his collection when he was just a child and had inherited his father's billiard table. From that day on, he had become fascinated with the round, glossy orbs. He would spend all of his free time scouring thrift stores, garage sales, and online marketplaces in search of new additions to his collection.

Over the years, Peter had amassed an impressive collection. He had billiard balls of all shapes, sizes, and colors. Some were made of ivory, others of marble, and still others of various types of wood. He had even managed to find a set of gold-plated billiard balls that he kept under lock and key.

Despite his love for his collection, Peter never let it interfere with his work as a veterinarian. He was always there to help animals in need, and his patients loved him for his kind and gentle manner.

One day, however, Peter received a call from a farmer w

@hakanensari
hakanensari / 1_create_products.rb
Created April 30, 2013 23:47
Sequel + uuid-ossp
Sequel.migration do
up do
run 'CREATE EXTENSION "uuid-ossp"'
create_table :products do
column :id, :uuid, :default => Sequel.function(:uuid_generate_v4), :primary_key => true
end
end
end
@hakanensari
hakanensari / benchmark.rb
Created October 3, 2012 18:47
PostgreSQL update strategies in and around Rails
require 'active_record'
require 'activerecord-import'
require 'benchmark'
require 'pg'
include ActiveRecord
Base.establish_connection adapter: 'postgresql',
encoding: 'unicode',
pool: 5,
@hakanensari
hakanensari / gist:2029402
Created March 13, 2012 15:25
Remove all tags in a repo
# Local
git tag -l | xargs git tag -d
# Remote
git ls-remote --tags origin | awk '/^(.*)(\s+)(.*[a-z0-9])$/ {print ":" $2}' | xargs git push origin
{
"Request": {
"IsValid": "True",
"ItemLookupRequest": {
"Condition": "All",
"DeliveryMethod": "Ship",
"IdType": "ASIN",
"MerchantId": "All",
"OfferPage": "1",
"ItemId": "0912383119",
<Notification>
<NotificationMetaData>
<NotificationType>AnyOfferChanged</NotificationType>
<PayloadVersion>1.0</PayloadVersion>
<UniqueId>14baf090-6a81-4d13-b1ad-340363d569d8</UniqueId>
<PublishTime>2014-02-23T11:35:40.497Z</PublishTime>
<SellerId>MERCHANT_ID_1</SellerId>
<MarketplaceId>A2EUQ1WTGCTBG2</MarketplaceId>
</NotificationMetaData>
<NotificationPayload>
require 'benchmark'
require './lib/excon'
include Excon
uris = {
'Good URI' => "http://example.org/#{'foo/' * 10}?#{10.times.map { 'bar=baz' }.join('&')}",
'Bad URI' => "http://example.org/#{'foo /' * 10}?#{10.times.map { 'bar=baz' }.join('&')}"
}