Skip to content

Instantly share code, notes, and snippets.

View SerKnight's full-sized avatar
🏄‍♂️

Christopher Knight SerKnight

🏄‍♂️
View GitHub Profile
@SerKnight
SerKnight / link.rb
Created June 24, 2013 21:53
Hacktivism: VideoValidator and Embedding
@SerKnight
SerKnight / index.haml
Last active December 28, 2015 14:49
html, css, jquery, ajaxhttp://www.nylonmag.com/models
= render :partial => 'shared/carousel', :locals => { :id => 'models-carousel', :type=> 'hero', :arrows => true, :carousel_items => @carousel_items }
#model-hashtag.hashtag
#model-filter
#savemodel
#model-post-count
0
#refresh
= link_to 'refresh', '/models/random-refresh?model_id='+@selected_model.id.to_s, remote: true
%br
@SerKnight
SerKnight / snips.js
Last active August 29, 2015 14:16
Adventure Local .js snips
// cookie assign for converting visits to users
function signup_cookie(){
signinClick();
$(document).ready(function(){
if( $(window).width() > 400 ){
if((!$.cookie('signup') && (location.pathname.indexOf('adventures') == 1 || location.pathname.indexOf('blog') == 1) )){
@SerKnight
SerKnight / ruby_gists.rb
Last active August 29, 2015 14:16
advlo.rb
# adventure controller
class AdventuresController < ApplicationController
include ApplicationHelper
def index
if params[:region]
region = params[:region]
filter_index('region'.to_sym,region)
@SerKnight
SerKnight / FaceBlock.ts
Last active March 18, 2019 04:49
Example smart contract for a simple DApp: Faceblock
/* Can compare deploying a smart contract to tightly versioning an API.
Once a smart contract is distrubted & added to ETH it can never be removed.
Updates to a smart contract, require a re-deployment.
*/
pragma solidity ^ 0.4 .19;
contract FaceBlock {
// We declare high level variables & types used throughout contract
mapping(address => uint256) private addressToIndex;
@SerKnight
SerKnight / Insomnia_workspace.json
Created February 3, 2020 22:22
Insomnia workspace to accompany Xero API tutorial
{
"_type":"export",
"__export_format":4,
"__export_date":"2020-02-03T22:17:29.587Z",
"__export_source":"insomnia.desktop.app:v7.0.6",
"resources":[
{
"_id":"req_1a56b9b120a94264b79018d1ecee95f3",
"authentication":{
"accessTokenUrl":"https://identity.xero.com/connect/token",
@SerKnight
SerKnight / authorization-headers-and-body.rb
Created June 3, 2020 20:29
Xero Migration Tutorial - 1
authorization_headers = "OAuth oauth_consumer_key='#{CONSUMER_KEY}',
oauth_nonce='#{NONCE}',
oauth_signature_method='#{SIGNATURE_METHOD}',
oauth_timestamp='#{TIMESTAMP}',
oauth_token='#{TOKEN}',
oauth_version='1.0',
tenantType='ORGANISATION',
oauth_signature='#{oauth_signature}'".gsub("\n",' ')
=> "OAuth oauth_consumer_key='YOUR_CONSUMER_KEY', oauth_nonce='1cbf3d69-d478-4956-b574-a4c6c4a4b2c4', oauth_signature_method='RSA-SHA1', oauth_timestamp='1591214409', oauth_token='VALID_OAUTH_10A_ACCESS_TOKEN', oauth_version='1.0', tenantType='ORGANISATION', oauth_signature='dkkQVrBsTfWqCatt4AmInAtee3Aitmje5jtjjoWl0HZl%2BuriiCjY%2Fe%2FgM9M9XW75DeRXX1GYpeiJI6B0ogGylF9myRTv6KhDpEpiFe5tdaJ0b2LdcWbODHhLP98%f4LKCJVPaS9Y6atX8734qDx1z0hLhVREIDtNFEb%2BpyTpgejeI%3D'"
@SerKnight
SerKnight / authorization-headers-and-body.rb
Last active June 8, 2020 22:46
OAuth migration tutorial - 1
params = {
"scope": "offline_access accounting.transactions accounting.settings",
"client_id": "YOUR_OAUTH2_CLIENT_ID",
"client_secret": "YOUR_OAUTH2_CLIENT_SECRET"
}
@SerKnight
SerKnight / setup-base-params.rb
Last active June 5, 2020 19:30
OAuth migration tutorial - 2
base_params = "oauth_consumer_key=#{CONSUMER_KEY}" +
"&oauth_nonce=#{NONCE}" +
"&oauth_signature_method=#{SIGNATURE_METHOD}" +
"&oauth_timestamp=#{TIMESTAMP}" +
"&oauth_token=#{TOKEN}" +
"&oauth_version=1.0" +
"&tenantType=ORGANISATION"
@SerKnight
SerKnight / sign_sbs_with_private_key.rb
Created June 3, 2020 20:37
OAuth migration tutorial - 3
require 'uri'
require 'base64'
require 'openssl'
require 'digest/sha1'
signing_key = File.read('./privatekey.pem')
rsa_key = OpenSSL::PKey::RSA.new signing_key
digest = OpenSSL::Digest::SHA1.new
signature = rsa_key.sign(digest, signature_base_string)