Skip to content

Instantly share code, notes, and snippets.

View sonsongithub's full-sized avatar

Yuichi Yoshida sonsongithub

View GitHub Profile
### Keybase proof
I hereby claim:
* I am sonsongithub on github.
* I am sonson (https://keybase.io/sonson) on keybase.
* I have a public key whose fingerprint is E21F A289 4EA6 4A20 6BCA F297 E32E E7C2 5FFC 53CA
To claim this, I am signing this object:
require 'nokogiri'
require 'net/http'
require 'json'
def getHTML(url)
begin
uri = URI.parse(url)
response = Net::HTTP.start(uri.host, uri.port) do |http|
http.open_timeout = 15
http.read_timeout = 15
@sonsongithub
sonsongithub / camera.swift
Created July 25, 2016 23:40
How to use camera in Swift.
import UIKit
import PlaygroundSupport
import AVFoundation
import AVKit
import QuartzCore
private class CameraViewController: UIViewController, PlaygroundLiveViewMessageHandler, AVCaptureVideoDataOutputSampleBufferDelegate {
var input:AVCaptureDeviceInput!
@sonsongithub
sonsongithub / download.sh
Created July 13, 2016 02:55
script to download Caffe models.
./scripts/download_model_binary.py models/bvlc_reference_caffenet
./scripts/download_model_binary.py models/bvlc_alexnet
./scripts/download_model_binary.py models/bvlc_reference_rcnn_ilsvrc13
./scripts/download_model_binary.py models/bvlc_googlenet
@IBAction func push(sender: AnyObject) {
print("push")
let s1 = 100
let ptr1 = UnsafeMutablePointer<UInt8>(allocatingCapacity: s1)
for i in 0 ..< s1 {
(ptr1 + i).pointee = UInt8(10)
}
(ptr1 + 200).pointee = UInt8(10)
ptr1.deallocateCapacity(0)
}
@sonsongithub
sonsongithub / ssl_check.rb
Created June 7, 2016 16:11
SSLの証明書の期限をJSONで書き出すコード
require 'json'
require 'date'
r = []
hosts = []
hosts.each{|host|
if`sudo openssl x509 -in /etc/letsencrypt/live/#{host}/fullchain.pem -noout -dates` =~ /notAfter=(.+?)$/
entry = {}
@sonsongithub
sonsongithub / uploader.m
Created May 29, 2016 19:47
To upload an image to imgur.com in Objective-C.
NSString *clientID = @"your client ID";
NSString *XMashapeKey = @"your key";
NSMutableCharacterSet *allowedCharacterSet = [NSMutableCharacterSet alphanumericCharacterSet];
[allowedCharacterSet addCharactersInString:@"-._~"];
NSString *base64 = [imageBinaryData base64EncodedStringWithOptions:0];
NSString *escapedBase64 = [base64 stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://imgur-apiv3.p.mashape.com/3/image"]];
@sonsongithub
sonsongithub / post.rb
Last active May 23, 2016 16:51
Ruby script to send Firebase notification.
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://fcm.googleapis.com/fcm/send')
http_proxy = ENV['HTTP_PROXY']
https_proxy = ENV['HTTPS_PROXY']
proxy_host = nil
@sonsongithub
sonsongithub / CodePiece.swift
Created May 7, 2016 06:15
さっきのコード #CodePiece #yidev
protocol Photo {
func getName() -> String
}
struct Facebook: Photo {
func getName() -> String {
return "facebook"
}
}
@sonsongithub
sonsongithub / CodePiece.swift
Created May 7, 2016 05:16
試し #CodePiece
var cell = tableView.dequeueReusableCellWithIdentifier(contents.cellIdentifier)