Skip to content

Instantly share code, notes, and snippets.

Avatar

Halil Özgür halilim

View GitHub Profile
@halilim
halilim / My_Termux_Customizations.md
Last active Jul 14, 2020
My Termux customizations. Since I'm not aware of a simpler way of syncing them I just created this. They are mostly subsets of my desktop configs.
View My_Termux_Customizations.md

Installation

# TODO: Add steps for Zsh & oh-my-zsh: https://wiki.termux.com/wiki/ZSH
git clone https://gist.github.com/6f1c30a51577c2b0370415f210093ba1.git ~/termux_gist
bash ~/termux_gist/setup.sh
@halilim
halilim / Chrome_remove_auto_search_engines.js
Last active Jul 4, 2017
Remove automatically created search engines from Chrome.
View Chrome_remove_auto_search_engines.js
var others = document.querySelectorAll("#other-search-engine-list .deletable-item:not([lead=lead])");
var toBeRemoved = [...others].filter(function(listItem) {
var keyword = listItem.querySelector(".keyword-column .static-text").innerText;
return keyword.includes(".") &&
listItem.querySelector(".url-column .static-text").innerText.toLowerCase().includes(
keyword.toLowerCase()
);
});
if (confirm(`Search engines: \
${document.querySelectorAll("#default-search-engine-list .deletable-item").length} default, \
@halilim
halilim / daily_whois_halil_im.js
Last active May 24, 2017
Simple AWS Lambda script to notify by SNS if a domain is expiring within 3 days
View daily_whois_halil_im.js
// Simple AWS Lambda function to notify if the domain halil.im is expiring within 3 days.
// Tested on Node.js 6.10 runtime.
// * Create an SNS topic and an SNS subscription with the email you want to be notified
// * Create the function with a trigger of "CloudWatch Events - Schedule" with rate: 1 day
// * Provide the SNS topic ARN to the function as an environment variable
// * Create and attach a policy to the role of this function with sns:Publish on the SNS topic ARN
// (logs:CreateLogGroup, logs:CreateLogStream & logs:PutLogEvents on a logs ARN should already be there)
/* eslint-env node,es6 */
/* eslint no-console: "off" */
@halilim
halilim / check.md
Last active Jul 14, 2020
Text editor color theme test
View check.md

(Open the files in your editor and try out different color schemes)

It should highlight Markdown headers

It should handle basic styling like inline code, italic text, bold text, but should not italicize_inline under_lined text.

  • A list item
  • Some inline code
  • Etc lorem ipsum
View find_uniq.rb
require 'set'
def find_uniq(ids)
# O(n) space
# uniqs = Set.new
# ids.each do |id|
# uniqs.delete(id) unless uniqs.add?(id)
# end
# uniqs.first
# O(1) space
@halilim
halilim / trace_calls.rb
Created Mar 21, 2016
A refactoring of TraceCalls (Metaprogramming - Programming Ruby 1.9 & 2.0, 4th edition)
View trace_calls.rb
module TraceCalls
def self.included(base)
[base, base.singleton_class].each do |klass|
klass.instance_methods(false).each do |existing_method|
wrap(klass, existing_method)
end
end
def base.method_added(method)
TraceCalls.run_method_added(self, method, __method__)
@halilim
halilim / inheritance_hierarchy.rb
Last active Aug 20, 2016
Demonstrating Ruby class/module method inheritance hierarcy
View inheritance_hierarchy.rb
module Extendable # :nodoc:
def self.extended(base)
base.include InstanceMethods
end
module InstanceMethods # :nodoc:
def hello
puts 'hello from Extendable'
super
end
@halilim
halilim / move_heroku_pg_to_aws_rds.md
Last active Feb 8, 2020
Move Heroku Postgres to Amazon AWS RDS
View move_heroku_pg_to_aws_rds.md
  1. Prepare your RDS instance and [authorize access to it][1] (basically make it public).

  2. Put your app in maintenance mode:

    heroku maintenance:on
  3. Save the latest SQL dump of the DB:

View keybase.md

Keybase proof

I hereby claim:

  • I am halilim on github.
  • I am halil (https://keybase.io/halil) on keybase.
  • I have a public key ASCTFoy6Tqz9aQRrOCeOjMkn9M_xyoPNpU3g5_mbYMCpTgo

To claim this, I am signing this object:

View ruby_cryptology.rb
CIPHER = { 'a' => 'n', 'b' => 'o', 'c' => 'p', 'd' => 'q',
'e' => 'r', 'f' => 's', 'g' => 't', 'h' => 'u',
'i' => 'v', 'j' => 'w', 'k' => 'x', 'l' => 'y',
'm' => 'z', 'n' => 'a', 'o' => 'b', 'p' => 'c',
'q' => 'd', 'r' => 'e', 's' => 'f', 't' => 'g',
'u' => 'h', 'v' => 'i', 'w' => 'j', 'x' => 'k',
'y' => 'l', 'z' => 'm' }.freeze
REVERSE_CIPHER = CIPHER.invert.freeze
You can’t perform that action at this time.