Skip to content

Instantly share code, notes, and snippets.

View vasmani's full-sized avatar

Jihong Lee vasmani

View GitHub Profile
@vasmani
vasmani / MQTTSubscribe.sh
Created January 10, 2021 22:55 — forked from David-Lor/MQTTSubscribe.sh
Shell Script to subscribe to MQTT and execute a callback
#!/bin/bash
# This script subscribes to a MQTT topic using mosquitto_sub.
# On each message received, you can execute whatever you want.
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h "127.0.0.1" -t "test" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
@vasmani
vasmani / ir-test.ino
Last active April 16, 2016 05:05
Arduino IR receiver test
// library from http://z3t0.github.io/Arduino-IRremote/
// IR receiver는 볼록한 곳을 전면으로 하여 왼쪽부터 D11, GND, 5V 연결
// 각종 IR 리모콘의 값을 확인 할 수 있다.
#include <IRremote.h>
#include <IRremoteInt.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
@vasmani
vasmani / pw.js
Last active March 22, 2016 00:50
sgp2-osx-shell-nodejs
#!/usr/bin/env node
// http://files.supergenpass.com/js/sgp2_0.js
function b64_md5(p) {
p=utf8_en(p);
return binl2b64(core_md5(str2binl(p),p.length*8));
}
function hex_md5(p) {
p=utf8_en(p);
#include <NewPing.h>
#include <TM1637Display.h>
const int CLK = 2; //Set the CLK pin connection to the display
const int DIO = 3; //Set the DIO pin connection to the display
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
@vasmani
vasmani / gist:2c5dfd4cc8ac328fca71
Last active February 23, 2016 04:02
구피 사료주기 - RF와 모터 이용
#include "RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
#include <Servo.h>
RCSwitch mySwitch = RCSwitch();
Servo myservo;
int pos = 0;
void setup() {
@vasmani
vasmani / gist:13f59469ac1317c2041e
Created June 2, 2015 01:27
google photos assistant helper
/*
1. open https://photos.google.com/assistant
2. open console
3. paste codes below
*/
var elements = document.querySelectorAll('.GuNJec div[role=button]');for(var i=0;i<elements.length;i++){elements[i].click();}
@vasmani
vasmani / gist:b14d3476d629ba0635fb
Created February 2, 2015 15:11
Raspberry Pi - USB Audio에서 사운드 깨짐 발생할 때
// http://wiki.linuxaudio.org/wiki/raspberrypi 에 따르면
Force USB1.1 mode
The RPi has a USB2.0 controller that apparently can cause issues with USB1.1 audio interfaces. The solution is to force the controller to use USB1.1 mode. You can do this by adding the following kernel parameter to your /boot/cmdline.txt file on your RPi:
dwc_otg.speed=1
@vasmani
vasmani / context.xml
Last active August 29, 2015 14:14
Spring MVC + Theme 설정
<!--
Request중 theme 변수가 있는 경우 theme을 설정한다(cookie).
예를 들어, /index?theme=default 호출시
resources/theme/theme-default.properties 파일을 찾는다.
theme-default.properties파일에는 아래와 같은 내용이 있다.
css=/resources/lib/bootstrap/css/bootstrap.min.css
view단에서
<link rel="stylesheet" href="<spring:theme code='css'/>" type="text/css"/> (JSP)
@vasmani
vasmani / gist:2c2ee7410222014448fa
Last active August 29, 2015 14:10
Arduino FDD Music
// http://www.classicpianosolos.com/sheetmusic/bach/bach-bwv-784-invention-no.-13-719
#define Dir 3
#define Step 6
int DD = HIGH;
int current = 0;
int c1 = 7000;
int d1 = 6500;
@vasmani
vasmani / gist:65ce389ad514b2fecde9
Created October 12, 2014 14:46
라즈베리파이 wlan 설정
# /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp