Skip to content

Instantly share code, notes, and snippets.

View xta's full-sized avatar

Rex Feng xta

View GitHub Profile
require 'sqlite3'
require 'debugger'
DB = SQLite3::Database.new("studentbody.db")
create_students_table_sql = <<SQL
CREATE TABLE students
(
id INTEGER PRIMARY KEY,
first_name TEXT,
@brandonhilkert
brandonhilkert / backbone.rails.js
Created August 26, 2012 19:01 — forked from somebox/backbone.rails.js
Makes Backbone.js with Rails+CSRF
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@albrow
albrow / Rakefile
Last active December 10, 2015 05:08
An excerpt from the Rakefile I use to deploy my blog. http://blog.alexbrowne.info
# ...
desc "Deploy website to s3/cloudfront via aws-sdk"
task :s3_cloudfront => [:generate, :minify, :gzip, :compress_images] do
puts "=================================================="
puts " Deploying to Amazon S3 & CloudFront"
puts "=================================================="
# setup the aws_deploy_tools object
config = YAML::load( File.open("_config.yml"))
chris@luna ~ (master*) $ telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /?name=Chris HTTP/1.0
HTTP/1.1 200 OK
Content-Type: text/html
Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
Date: Sat, 13 Apr 2013 00:07:11 GMT
@olov
olov / gist:eb60ab878eb73a7c5e22
Created October 15, 2014 08:55
listenandservetls_nossl30.go
// You don't want to serve HTTPS supporting for SSL3.0 any longer, see:
// http://googleonlinesecurity.blogspot.de/2014/10/this-poodle-bites-exploiting-ssl-30.html
import (
"crypto/tls"
"net/http"
)
// This code supports SSL3.0, TLS1.0, TLS1.1 and TLS1.2
// Chances are you currently do this but want to stop due to the POODLE
err := http.ListenAndServeTLS(addr, "crtfile", "keyfile", handler)
describe "GET current" do
before do
@request.cookies['hidden_notices'] = "1,#{notices(:permanent).id}"
get :current, :format => 'js'
end
it { should respond_with(:success) }
it { should set_cookie(:hidden_notices).to("#{notices(:permanent).id}") }
it { should render_template('notices/current') }
end
@goodmike
goodmike / Arel Multi-join example.rb
Created July 23, 2010 17:26
Implementing multiple joins with Arel
# The problem: In your Rails 3 project, you have a model Request that models a
# user's request for content related to a specific problem or topic. The user
# can tag her request with any number of words. These are modeled by a Tag class
# backed by a tags DB table. Since you want unique records per tag, you have a
# Tagging class backed by a taggings table. Taggings is a a many-to-many table
# with some additional information. Also, other models in the application
# besides requests can be tagged: The Tagging class defines a polymorphic
# relationship "taggable" with those models.
#
# So pretty soon you want to look up all the requests that are tagged with
@alexaandru
alexaandru / stf2017.md
Last active July 7, 2019 08:02
State of The Frontend. 2017

State of The Frontend

Special thanks to https://scotch.io/tutorials/create-a-single-page-app-with-go-echo-and-vue for resparking my interest for frontend development. It's been a while... :)

2019 Update

// Sample event data for a proxy request
// {
// "resource": "Resource path",
// "path": "Path parameter",
// "httpMethod": "Incoming request's method name"
// "headers": {Incoming request headers}
// "queryStringParameters": {query string parameters }
// "pathParameters": {path parameters}
// "stageVariables": {Applicable stage variables}
// "requestContext": {Request context, including authorizer-returned key-value pairs}
@mhulse
mhulse / Amazon S3 snippets and Transmit FTP cloud settings.md
Last active February 21, 2021 18:36
Amazon S3 snippets... Transmit FTP cloud settings... Other related goodies...

S3 Website "Index Document"

index.html:

<html>
<head>
<title>403 Forbidden</title>
</head>
<body>