Skip to content

Instantly share code, notes, and snippets.

View tamersalama's full-sized avatar

Tamer Salama tamersalama

View GitHub Profile
@vulcan25
vulcan25 / run.py
Last active January 11, 2023 13:52
psycopg2 flask implementation with connection pooling support
from flask import Flask, g, jsonify
import werkzeug, os
from werkzeug.utils import secure_filename
import psycopg2
from psycopg2 import pool
def get_db():
print ('GETTING CONN')
if 'db' not in g:
@rbnpi
rbnpi / FrereSonatina.rb
Last active April 22, 2022 23:11
Using Sonatina Symphonic Library with Sonic Pi. Illustrated with a 19 voice round of Frere Jaques. Requires SP ver 2.10 or later an the Symphonic Library from https://github.com/peastman/sso Full article on this program at https://rbnrpi.wordpress.com/2016/03/16/sonatina-symphonic-orchestra-revisited-to-give-55-sample-voices-for-sonic-pi/
#program to utilise 48 different sample voices from Sonatina Symphonic Library
#written by Robin Newman, March 2016
#requires Sonatina Symphonic Library from http://sso.mattiaswestlund.net/download.html
#requires Sonic Pi ver 2.10
#plays 19 voice Frere Jqeus round!
#tested on Pi2, Pi3, Mac OSX and Windows 10.
#updated to handle new thread structure in SP2.11dev
use_debug false
#path to library samples folder (including trailing /)
path='~/Desktop/Sonatina Symphonic Orchestra/Samples/'
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@dhh
dhh / Basecamp-DDOS.md
Last active August 30, 2023 09:33
Basecamp is under network attack (DDoS)

Basecamp was under network attack

The attack detailed below has stopped (for the time being) and almost all network access for almost all customers have been restored. We're keeping this post and the timeline intact for posterity. Unless the attack resumes, we'll post a complete postmortem within 48 hours (so before Wednesday, March 26 at 11:00am central time).

Criminals have laid siege to our networks using what's called a distributed denial-of-service attack (DDoS) starting at 8:46 central time, March 24 2014. The goal is to make Basecamp, and the rest of our services, unavailable by flooding the network with bogus requests, so nothing legitimate can come through. This attack was launched together with a blackmail attempt that sought to have us pay to avoid this assault.

Note that this attack targets the network link between our servers and the internet. All the data is safe and sound, but nobody is able to get to it as long as the attack is being successfully executed. This is like a bunch of people

@pullmonkey
pullmonkey / gist:3179054
Created July 25, 2012 22:18
httpi with curb (spnego and multipart file upload)
require 'rubygems'
require 'httpi'
require 'curb'
# at some point before the request is made you'll need a kerberos ticket
# i.e., kinit -k -t ticket_path
image_path = "/tmp/some_image.jpg"
url = URI.escape("https://some_ssl_spnego_url.com/upload_file_here")
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)