Skip to content

Instantly share code, notes, and snippets.

@waseem
waseem / query.graphql
Last active July 22, 2022 17:56
Github GraphQL repo commit history for commits made before a certain commit.
query {
repository(owner: "rails", name:"rails") {
ref(qualifiedName:"master") {
target {
... on Commit {
id
#
# We're are requesting commits in the multiple of 5. We can assume that the page size here is 5.
# Next page/cursor should use value in next multiples of 5s. So next page will have a
# after: "05eaa07627376626902bd7acde35406edf1bb2f2 5"
for v in range(height):
for u in range(width):
# Get end of ray and round to sdf array coordinate...
pos = start[v,u,:] + travel[v,u] * norm[v,u,:]
pos += 0.5 * numpy.array(sdf.shape) # Center of sdf to 3D origin
sdf_coordinate = (pos+0.5).astype(int)
# Loop the 3 dimensions and check each is not out of bounds...
for d in range(3):
if sdf_coordinate[d]<0:
@waseem
waseem / mailgun.rb
Last active October 19, 2018 10:54
Mailgun Webhook POST Request
{
"Message-Id"=>"<20130503182626.18666.16540@barcelonites.com>",
"X-Mailgun-Sid"=>"WyIwNzI5MCIsICJhbGljZUBleGFtcGxlLmNvbSIsICI2Il0=",
"attachment-count"=>"1",
"body-plain"=>"",
"code"=>"550",
"domain"=>"barcelonites.com",
"error"=>"5.1.1 The email account that you tried to reach does not exist. Please try\n5.1.1 double-checking the recipient's email address for typos or\n5.1.1 unnecessary spaces. Learn more at\n5.1.1 http://support.example.com/mail/bin/answer.py",
"event"=>"bounced",
"message-headers"=>"[[\"Received\", \"by luna.mailgun.net with SMTP mgrt 8734663311733; Fri, 03 May 2013 18:26:27 +0000\"], [\"Content-Type\", [\"multipart/alternative\", {\"boundary\": \"eb663d73ae0a4d6c9153cc0aec8b7520\"}]], [\"Mime-Version\", \"1.0\"], [\"Subject\", \"Test bounces webhook\"], [\"From\", \"Bob <bob@barcelonites.com>\"], [\"To\", \"Alice <alice@example.com>\"], [\"Message-Id\", \"<20130503182626.18666.16540@barcelonites.com>\"], [\"List-Unsubscribe\", \"<mailto:u+na6tmy3ege4tgnldmyytqojqmfsdemb
@waseem
waseem / easy_tunnel.rake
Created July 11, 2010 05:12
A Rake interface to creating a tunnel using ssh.
##
# A Rake interface to creating a tunnel using ssh.
# This file originally comes with the facebooker gem for Ruby on Rails: http://github.com/mmangino/facebooker
#
# How to use:
# 1. Simply put it at a proper place. e.g. lib/tasks/ in your Rails application
# 2. Create a config file 'easy_tunnel.yml' like following:
#
# development:
# public_host_username: host_user_name
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index 8c04cb5..132d803 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -104,6 +104,9 @@
have_func("SSLv2_method")
have_func("SSLv2_server_method")
have_func("SSLv2_client_method")
+have_func("SSLv3_method")
+have_func("SSLv3_server_method")
$ irb
2.0.0p0 :001 > s1 = "some thing"
=> "some thing"
2.0.0p0 :002 > s2 = s1
=> "some thing"
2.0.0p0 :003 > s2
=> "some thing"
2.0.0p0 :004 > s1 = "some other thing"
=> "some other thing"
2.0.0p0 :005 > s2
@waseem
waseem / create_videos.rb
Last active December 16, 2015 18:48
Integrating Zencoder API with Carrierwave in Rails
class CreateVideos < ActiveRecord::Migration
def change
create_table :videos do |t|
t.string :video
t.text :meta_info
t.timestamps
end
end
end
@waseem
waseem / company.rb
Last active December 15, 2015 05:29 — forked from anonymous/gist:5209780
class Company
attr_reader :title
def initialize(title)
@title = title.capitalize
@users = []
end
def add_company_name(new_comp)
@title = new_comp
@waseem
waseem / start.md
Last active December 14, 2015 09:50
How one should start learning Ruby and Rails.

If you're just starting with Rails, I will suggest you to learn Ruby first. If you know how its object model, inheritance and mixins work, you're good to start creating web application with it. This is very important. A lot of people dive into Rails without learning basic Ruby first (that's how I did) and get frustrated because they don't understand how it works. I will highly recommend The Well Grounded Rubyist by David Black to start learning Ruby. You can also get a good introduction of Ruby by working your way through interactive tutorials on Codeacademy. You don't need to understand metaprogramming in the beginning. But if you decide to do so, I will suggest book Metaprogramming Ruby by Paolo Perrotta. It's best in covering the subject matter. It's a little bit old though but still good nonetheless. Also see third point in [comment](https://gist.github.com/waseem/5068050/#

1. An issue popups in Github. A bug or a feature request.
2. Developer starts coding after understanding the issue. He makes sure to add issue number in the form of #XXX - XXX is issue number - to the commit message. This links issue with the commit that was made. It's important to know 'why the commit was made'.
3. A CI listens to pushes to the Github repo and runs all the specs and optionally deploys the code to one of the staging servers.
4. After developer is done with coding, s/he assigns the issue to another developer for code review.
5. Code reviewer makes sure that all the tests are passing along with presence of code and test coverage. Code reviewer can assign issue back to the developer if there is some issue with the code. Developer will start at step 1 again.
6. Code reviewer assigns issue to QA. If QA is not happy, s/he adds issues that were found as comment to the original issue or possibly create new issues depending upon severity of the problem s/he found out.
7. If QA is happy, she assigns th