Skip to content

Instantly share code, notes, and snippets.

View magicien's full-sized avatar
😴
Having a doze

magicien magicien

😴
Having a doze
View GitHub Profile
import Foundation
let json = """
{
"user_id": 1,
"user_name": "magicien",
"url": "http://darkhorse2.0spec.jp"
}
""".data(using: .utf8)!
import Foundation
let json = """
{
"user_id": 1,
"user_name": "magicien",
"friends": [
{
"user_id": 2,
"is_best_friend": true
import Foundation
let json = """
{
"user_id": 1,
"user_name": "magicien",
"friends": [
{
"user_id": 2,
"is_best_friend": true
import Foundation
let json = """
{
"user_id": 1,
"user_name": "magicien",
"friends": [
{
"user_id": 2,
"is_best_friend": true
import Foundation
let json = """
[
{ "name": "magicien" },
{ },
{ "name": "NoName" }
]
""".data(using: .utf8)!
import Foundation
// framework側のコード
let ExtensionKey = CodingUserInfoKey(rawValue: "extensionKey")!
struct Group: Codable {
let users: [User]
}
let url = URL(fileURLWithPath: pngFileName, relativeTo: directoryPath)
// let reddishImage = NSImage(contentsOf: url)
let cgDataProvider = CGDataProvider(url: url as CFURL)!
let cgImage = CGImage(pngDataProviderSource: cgDataProvider, decode: nil, shouldInterpolate: false, intent: CGColorRenderingIntent.defaultIntent)!
let imageSize = CGSize(width: cgImage.width, height: cgImage.height)
let correctImage = NSImage(cgImage: cgImage, size: imageSize)
import Foundation
let json = """
{
"nodes": [
{
"extensions": {
"KHR_materials_common": {
"light": 0
}
@magicien
magicien / CreateJWT.php
Created September 9, 2017 22:06
How to create JWT with lcobucci/jwt in PHP
<?php
require_once('../composer/vendor/autoload.php');
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Rsa\Sha256;
$signer = new Sha256();
$key = <<<EOT
-----BEGIN RSA PRIVATE KEY-----
@magicien
magicien / HerokuPassportGithub2.js
Last active September 13, 2017 20:23
Identifying Users for GitHub Apps at Heroku
const express = require('express')
const session = require('express-session')
const passport = require('passport')
const GitHubStrategy = require('passport-github2').Strategy
const clientId = process.env.GITHUB_APP_CLIENT_ID
const clientSecret = process.env.GITHUB_APP_CLIENT_SECRET
const domainName = process.env.DOMAIN_NAME
const app = express()