Skip to content

Instantly share code, notes, and snippets.

@dnkm
dnkm / 01_basic.cpp
Created April 1, 2025 23:55
c++ pointers and references
#include <bits/stdc++.h>
using namespace std;
int main() {
int x = 10;
cout << x << endl;
cout << &x << endl;
cout << *(&x) << endl;
int *y = &x;
@dnkm
dnkm / Bank.java
Last active February 26, 2025 01:54
Katherine - private class - 2025 Feb 25
class Bank {
private int balance;
public Bank(int initBalance) {
balance = initBalance;
}
public void add(int amt) {
if (amt <= 0) {
System.out.println("huh?");
@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));
}
}