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
@magicien
magicien / CMakeLists.txt.after
Created May 19, 2020 18:10
EOSサンプル修正後の CMakeLists.txt
#CMAKE file for build
project (SimpleFramework)
cmake_minimum_required(VERSION 2.6)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) #default type is release
endif()
@magicien
magicien / compare_array_filter_performance.js
Last active April 15, 2020 18:45
Comparing performance to filter items of an array in JavaScript
// Comparing performance to filter items of an array.
// I want to convert array data, but I don't want to include some of the data.
const N = 50000;
const data = [];
for(let i=0; i<N; i++) {
data.push(i);
}
@magicien
magicien / checkout.sh
Last active December 11, 2019 10:36
chruby-disabled checkout script for CircleCI
#!/bin/sh
set -e
# Disable chruby
trap - DEBUG || true
# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
@magicien
magicien / commonprofile.metal
Created August 11, 2018 09:26 — forked from j-j-m/commonprofile.metal
Can't access GL Uniforms in Metal shader modifier? Apple docs for SCNShadable written in terms of GL? Pulling your hair out?... this will help.
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
public func Cross(_ q1: SCNQuaternion, _ q2: SCNQuaternion) -> SCNQuaternion {
return SCNQuaternion(
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x,
q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w,
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z
)
}
async function getResult(request) {
const promise = new Promise((resolve, reject) => {
request.onsuccess = () => {
resolve(request.result)
}
request.onerror = () => {
reject(request.error)
}
})
return promise
// サーバ側のコード
const express = require('express')
const fetch = require('node-fetch')
const app = express()
app.get('/githubapi/repos/:owner/:repo/:ref', (req, res) => {
const owner = req.params.owner
const repo = req.params.repo
const ref = req.params.ref
@magicien
magicien / Swift4_JSON_09.swift
Created October 3, 2017 00:54
How should I inherit Codable class?
import Foundation
let json = """
{
"a": 1,
"b": 2,
"c": 3
}
""".data(using: .utf8)!
import Foundation
import SceneKit
let json = """
{
"position": [2.0, 5.0, 3.0],
"rotation": [0.0, 0.73, 0.0, 0.73]
}
""".data(using: .utf8)!
const jwt = require('jsonwebtoken')
const fetch = require('node-fetch')
const appId = process.env.GITHUB_APP_ID
const privateKey = process.env.GITHUB_APP_PRIVATE_KEY
const getRepositories = (token) => {
return fetch('https://api.github.com/installation/repositories', {
headers: {
Authorization: `token ${token}`,