Skip to content

Instantly share code, notes, and snippets.

@ktcy
ktcy / FramerPS.jsx.patch
Created December 24, 2013 08:06
Framer.app/Contents/Resources/psjs/scripts/FramerPS.jsx
--- FramerPS.jsx.original 2013-10-15 15:31:26.000000000 +0900
+++ FramerPS.jsx 2013-12-24 16:20:33.000000000 +0900
@@ -14293,6 +14293,7 @@
var f;
try {
f = new File(path);
+ f.encoding = "UTF-8";
f.lineFeed = "Unix";
f.remove();
f.open('w');
function gaussianElimination(matrix) {
var pivot, base, col, div, mul, v, n, i, j;
n = matrix.length;
// Forward Elimination
for (pivot = 0; pivot < n - 1; pivot++) {
swap(matrix, pivot);
base = matrix[pivot];
@ktcy
ktcy / toremote
Last active August 29, 2015 14:27
$ toremote [--mac] [--windows] [path]
#!/usr/bin/env node
try {
var args = parseArguments();
if (args.help) {
console.log('Usage: toremote [--mac] [--windows] [path]');
process.exit(0);
}
@ktcy
ktcy / invpath
Last active August 29, 2015 14:27
$ invpath <path>
#!/usr/bin/env node
getOptions(function(options) {
if (!options.path) {
console.log('Usage: invpath <path>');
process.exit(0);
}
var path = options.path.trim();
var type = guess(path);
'use strict';
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
@ktcy
ktcy / CubicBezier.es6.js
Created September 18, 2015 11:35
CSS `cubic-bezier()` timing function
'use strict';
export default function cubicBezier(x1, y1, x2, y2) {
let ax, bx, cx, ay, by, cy;
ax = 3 * (x1 - x2) + 1;
bx = 3 * x2 - 6 * x1;
cx = 3 * x1;
ay = 3 * (y1 - y2) + 1;

Default settings to generate image assets for Android

Create empty layer and name it:

default 100% drawable-mdpi/ + 150% drawable-hdpi/ + 200% drawable-xhdpi/ + 300% drawable-xxhdpi/

Reference:

@ktcy
ktcy / circumcircle.js
Created April 20, 2017 09:03
Circumcircle from three points
function circumcircle(point0, point1, point2) {
const x1 = point1.x - point0.x;
const y1 = point1.y - point0.y;
const x2 = point2.x - point0.x;
const y2 = point2.y - point0.y;
const k = 2 * (x1 * y2 - y1 * x2);
if (k === 0) {
return null;
}
@ktcy
ktcy / index.html
Last active July 10, 2019 23:52
Spotify API Authorization
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Example of the Authorization Code flow with Spotify</title>
<style type="text/css">
#login, #loggedin {
display: none;
}
.text-overflow {
@ktcy
ktcy / silence.js
Created October 24, 2018 10:20
Create WAV file containing only silence
function createSilence(seconds = 1) {
const sampleRate = 8000;
const numChannels = 1;
const bitsPerSample = 8;
const blockAlign = numChannels * bitsPerSample / 8;
const byteRate = sampleRate * blockAlign;
const dataSize = Math.ceil(seconds * sampleRate) * blockAlign;
const chunkSize = 36 + dataSize;
const byteLength = 8 + chunkSize;