Skip to content

Instantly share code, notes, and snippets.

@decors
decors / gist:51a897eef68802f0f111
Last active January 15, 2016 03:52
Electron twitter OAuth
'use strict';
var remote = require('remote');
var BrowserWindow = remote.require('browser-window');
var Twitter = require('twitter');
var OAuth = require('oauth').OAuth;
var authUrl = "https://api.twitter.com/oauth/authenticate?oauth_token=";
var oauth = new OAuth(
'https://api.twitter.com/oauth/request_token',
@decors
decors / index.html
Last active September 18, 2021 15:45
Electron open-file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Electron</title>
</head>
<body>
<script>
var ipc = require('ipc');
@decors
decors / cli.cr
Created December 20, 2016 04:17
Crystal-lang CLI
require "option_parser"
class CLI
@version = "1.0.0"
@command_name = "cli"
@options : Hash(Symbol, Bool | Nil | String) = {
:bool => false,
:string => nil
} of Symbol => Bool | Nil | String
@command : String?
@decors
decors / delegate.cr
Created January 26, 2017 04:35
Crystal-lang simple delegator
class Delegator(T)
def initialize(@object : T)
end
def self.delegate(object)
new(object)
end
forward_missing_to @object
end
@decors
decors / http_multipart_post.cr
Last active September 10, 2021 11:13
Crystal-lang HTTP Multipart/form-data POST
require "http/client"
class MultiPartFormData
property io : IO::Memory
property size : Int32
def initialize(name, filename, file, boundary=nil)
@boundary = boundary || "boundary"
first = [boundary_line, content_disposition(name, filename), "", ""].join("\r\n")
last = ["", boundary_last, ""].join("\r\n")
@io = IO::Memory.new