Skip to content

Instantly share code, notes, and snippets.

@dnkm
dnkm / id-cache.ts
Created May 19, 2020 22:18
indexeddb cache
import Dexie from "dexie";
import { addMinutes } from "date-fns";
import { firestore } from "firebase";
const DB_NAME: string = "id_cache";
const DB_VER: number = 1;
class IdCache {
db: Dexie;
@dnkm
dnkm / sphera.js
Last active February 27, 2019 01:27
Sphera Project
class Sphera {
constructor({
x = 0,
y = 0,
radius = 10,
color = Sphera.colors[parseInt(Math.random() * Sphera.colors.length)],
speed = 1,
angle = 0,
text = '',
border = 0,
@dnkm
dnkm / dijkstra.java
Last active October 28, 2018 23:34
dijk
import java.util.*;
public class dijk {
public static void main(String[] args) {
Graph g = new Graph(9);
g.addEdge(0, 1, 4);
g.addEdge(0, 7, 8);
g.addEdge(1, 2, 8);
g.addEdge(1, 7, 11);
@dnkm
dnkm / Messages.js
Created October 14, 2018 08:33
junha, justin
import React, { Component } from 'React';
import {
StyleSheet,
Text,
View,
Dimensions,
TextInput,
TouchableOpacity,
ScrollView,
Keyboard
@dnkm
dnkm / App.js
Created September 9, 2018 05:06
side menu demo
import React from 'react';
import { StyleSheet, Text, View, Button, Dimensions, Animated, Easing, TouchableOpacity } from 'react-native';
const SideMenu = () => (
<View>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
</View>
);
Broken Necklace
You have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, others blue, and others white, arranged at random. Here are two examples for n=29:
1 2 1 2
r b b r b r r b
r b b b
r r b r
r r w r
b r w w
@dnkm
dnkm / calendar.js
Created July 14, 2018 21:49
DOM API Calendar
class Calendar {
constructor(container) {
this.container = container;
this.today = new Date();
this.render();
}
renderHeader() {
let today = this.today;
let container = this.container;
@dnkm
dnkm / app.js
Last active March 15, 2018 19:32
yoon homework
const loadData = (cb) => {
const req = new XMLHttpRequest();
const url = "https://yoon2-hastedk.c9users.io/team/manu";
req.onreadystatechange = () => {
console.log("received", req.readyState, req.status);
if(req.readyState == 4 && req.status == 200) {
cb(JSON.parse(req.responseText));
}
}
@dnkm
dnkm / 0_reuse_code.js
Created August 3, 2016 21:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dnkm
dnkm / relayServer.js
Created July 2, 2016 07:22
Photo Proxy Server
/*
Simple web server that proxies a remote image
run: simple-server . $PORT
*/
var http = require('http');
var url = require('url');
var request = require('request');