Skip to content

Instantly share code, notes, and snippets.

View watzon's full-sized avatar
👀
Looking for work

Chris Watson watzon

👀
Looking for work
View GitHub Profile
@watzon
watzon / apex.js
Created August 17, 2016 05:25
Salesforce Ajax Toolkit
if (!sforce) {
throw "unable to find sforce. Make sure that connection.js is loaded before apex.js script";
}
sforce.Apex = function(){
};
sforce.RunTestsRequest = function() {
# A very basic HTTP server
require "http/server"
server = HTTP::Server.new(8080) do |context|
context.response.content_type = "text/plain"
context.response.print "Hello world, got #{context.request.path}!"
end
puts "Listening on http://127.0.0.1:8080"
server.listen
@watzon
watzon / payload.xml
Created October 29, 2016 18:54
Snippet for an article on Medium
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header xmlns="http://soap.sforce.com/schemas/package/AngularAppController">
<SessionHeader>
<sessionId>00D36000000b28L!ARsAQJJ....</sessionId>
</SessionHeader>
</soapenv:Header>
<soapenv:Body xmlns="http://soap.sforce.com/schemas/package/AngularAppController">
<executeQuery>
<query>SELECT Id, Salutation, FirstName, LastName, PhotoUrl FROM Contact</query>
@watzon
watzon / ApexController.cls
Created October 29, 2016 18:58
Snippet for article on Medium
global class AngularAppController {
@RemoteAction
WebService static List<sObject> executeQuery(String query) {
return Database.query(query);
}
}
@watzon
watzon / PGKBUILD
Last active July 11, 2017 22:16
Omnisharp Roslyn PKGBUILD
# Maintainer: sixpindin <sixpindin@gmail.com>
pkgname=omnisharp-roslyn
pkgver=1.22.0
pkgrel=1
pkgdesc=".NET development platform based on on Roslyn workspaces."
arch=('x86_64')
url="https://github.com/OmniSharp/omnisharp-roslyn"
license=('MIT')
depends=('mono-git', 'libuv')
noextract=('$pkgname-$pkgver.tar.gz')
type
NodeKind = enum
nkValue,
nkLiteral,
nkSymbol,
nkPair,
nkLookupVal,
nkIf,
nkIfAsync,
nkInlineIf,
@watzon
watzon / gen_ssh_key.sh
Created July 31, 2017 07:21
SSH Key Generation for .zshrc
function gen_ssh_key {
# Generate an ssh key
filename=${2:-"~/.ssh/id_rsa"}
ssh-keygen -f $filename -t rsa -b 4096 -C "$1" -N ""
if hash xclip 2>/dev/null; then
cat $2.pub | xclip -selection clipboard
elif hash pbcopy 2>/dev/null; then
cat $2.pub | pbcopy
else
@watzon
watzon / gsub-vs-split_join.cr
Created August 13, 2017 16:23
Crystal Benchmark - gsub vs split & join
require "benchmark"
Benchmark.ips do |x|
str = "this is text with too many spaces in it"
x.report("gsub") do
500.times { str = str.gsub(/\s+/, " ") }
end
x.report("split/join") do
500.times { str = str.split().join(" ") }
end
@watzon
watzon / redirect.html
Created September 1, 2017 22:18
Blogger Redirect
<script type="text/javascript">
window.location = "http://yoursite.com/yourpage";
</script>
require "file"
require "telegram_bot"
require "./definebot/*"
TOKEN = File.read(File.join(__DIR__, "..", ".secret-token"))
module Definebot
class Bot < TelegramBot::Bot
include TelegramBot::CmdHandler