Skip to content

Instantly share code, notes, and snippets.

Avatar

Omar Bohsali omarish

View GitHub Profile
@omarish
omarish / newpost.rb
Last active May 8, 2018
Script to make a new post in Jekyll.
View newpost.rb
#!/usr/bin/env ruby
require 'optparse'
options = {
:subdir => "_posts"
}
parsed = OptionParser.new do |opts|
opts.banner = 'Usage: newpost --title "post title" [options]'
View palindrome_signup.py
import mutations
class UserSignup(mutations.Mutation):
"""Sign up the user if and only if their name is a palindrome. """
name = mutations.fields.CharField()
email = mutations.fields.CharField()
def validate_name_is_palindrome(self):
"""
Since this method is prefixed with validate_, it's assumed to be
View mutations.py
import mutations
class UserSignup(mutations.Mutation):
name = mutations.fields.CharField()
email = mutations.fields.CharField()
def execute(self):
user = User.objects.create([...])
if user.is_referred_through_partner:
[...]
View keybase.md

Keybase proof

I hereby claim:

  • I am omarish on github.
  • I am obb (https://keybase.io/obb) on keybase.
  • I have a public key ASDIeAVpKvwV3vCq56hv4VTRXv_wNzmDUIvvTUJiMJwrhwo

To claim this, I am signing this object:

View scottrade.md

Dear Client:

We are writing to share with you important information about a security compromise involving a database containing some of your personal information, as well as steps we are taking in response, and the resources we are making available to you.

What Happened

Federal law enforcement officials recently informed us that they’ve been investigating cybersecurity crimes involving the theft of information from Scottrade and other financial services companies. We immediately initiated a comprehensive response.

Based upon our subsequent internal investigation coupled with information provided by the authorities, we believe a list of client names and street addresses was taken from our system. Importantly, we have no reason to believe that Scottrade’s trading platforms or any client funds were compromised. All client passwords remained encrypted at all times and we have not seen any indication of fraudulent activity as a result of this incident.

@omarish
omarish / Load_CSV_to_Vertica.md
Last active Dec 8, 2019
Quick primer on loading a large CSV file into a Vertica Database.
View Load_CSV_to_Vertica.md

Load a Large CSV into Vertica

Here's an efficient way to load a dataset into Vertica by splitting it up into multiple pieces and then parallelizing the load process.

Note that this only makes sense if your Vertica cluster is a single node. If it's running more nodes, there are definitely more efficient ways of doing this.

For this example, the large CSV file will be called large_file.csv. If your file is under 1GB, it probably makes sense to load it using a single COPY command.

View tmux.conf
# Setting the prefix from `C-b` to `C-a`.
# By remapping the `CapsLock` key to `Ctrl`,
# you can make triggering commands more comfottable!
set -g prefix C-a
# Free the original `Ctrl-b` prefix keybinding.
unbind C-b
# Ensure that we can send `Ctrl-a` to other apps.
bind C-a send-prefix
View mpg.csv
mpg cylinders displacement horsepower weight acceleration model_year origin name
18 8 307 130 3504 12 70 1 chevrolet chevelle malibu
15 8 350 165 3693 11.5 70 1 buick skylark 320
18 8 318 150 3436 11 70 1 plymouth satellite
16 8 304 150 3433 12 70 1 amc rebel sst
17 8 302 140 3449 10.5 70 1 ford torino
15 8 429 198 4341 10 70 1 ford galaxie 500
14 8 454 220 4354 9 70 1 chevrolet impala
14 8 440 215 4312 8.5 70 1 plymouth fury iii
14 8 455 225 4425 10 70 1 pontiac catalina
@omarish
omarish / server.py
Created May 2, 2013
A Tornado StaticFileHandler to disable static asset caching when you're in debug mode. Thanks to @didip for https://gist.github.com/didip/902931.
View server.py
import tornado.web
class NoCacheStaticFileHandler(tornado.web.StaticFileHandler):
def set_extra_headers(self, path):
self.set_header("Cache-control", "no-cache")
class Application(tornado.web.Application):
def __init__(self):
handlers = [
# ...
View mandlebrot.py
#!/usr/bin/env python
_ = (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)<6)else
( 2+c-4*abs(V)**-0.4)/i
) ;v, x=1500,1000;C=range(v*x
);import struct;P=struct.pack;M,\
You can’t perform that action at this time.