Skip to content

Instantly share code, notes, and snippets.

View samilkorkmaz's full-sized avatar

Şamil Korkmaz samilkorkmaz

  • Ankara / Turkey
View GitHub Profile
<html>
<head>
<meta charset="utf-8">
</head>
<!--body onload = "buttonClick()"-->
<body
<h1>Hello</h1>
<input id="myButton" type="button" value="click to discover bluetooth devices" onclick="buttonClick();">
<p id="info"></p>
</body>
@samilkorkmaz
samilkorkmaz / localStorageDemo.html
Created October 31, 2017 07:28
Local storage demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Local Storage Demo, 25.10.2017</h1>
<input type="text" id="key" placeholder="enter key" size = "10">
<input type="text" id="value" placeholder="enter value" size = "30">
<input type="button" value = "Save to localStorage" onclick = "saveToLocalStorage()">
@samilkorkmaz
samilkorkmaz / MyWebsocket.ino
Created November 3, 2017 18:24
ESP8266 websocket and webserver Arduino IDE script for sending potentiometer values.
/*
https://tttapa.github.io/ESP8266/Chap14%20-%20WebSocket.html
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <WebSocketsServer.h>
ESP8266WebServer server(80);
@samilkorkmaz
samilkorkmaz / MyWebsocket.html
Created November 3, 2017 18:25
HTML for getting potentiometer values through websocket
<!doctype html>
<html>
<head>
<meta name="HandheldFriendly" content="true"/>
<title>ESP8266 WebSocket</title>
<style>
input, button, body { font: 13px Helvetica, Arial; }
#messages { font: 15px Helvetica, Arial; }
</style>
</head>
@samilkorkmaz
samilkorkmaz / SimpleESPWebSocket.ino
Created November 11, 2017 17:27
Web socket with ESP8266 to send potentiometer values to client
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WebSocketsServer.h>
WebSocketsServer webSocket = WebSocketsServer(81);
long previousWiFiToggleMillis = 0;
int wsConnected = 0;
uint8_t wsClient;
long previousMillis = 0; // will store last time potentimeter value was sent via websocket
@samilkorkmaz
samilkorkmaz / espWebServer.ino
Last active November 20, 2017 19:59
ESP8266 webserver that returns potentiometer values to requests
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
ESP8266WebServer server(80);
const char* ssid = "YOUR SSID";
const char* password = "YOUR PASSWORD";
void handleRoot() {
package gsondemo;
import com.google.gson.Gson;
import java.util.Arrays;
/**
* GSON demo. Demonstrates effect of having no non-argument constructor on
* initialization of transient fields when creating an object from JSON string.
* Reference: https://stackoverflow.com/a/13532237/51358
* @author skorkmaz, April 2018, License: Public Domain
*/
public class GSONDemo {
@samilkorkmaz
samilkorkmaz / BeginInvoke.snippet
Created May 23, 2018 14:00
Visual Studio C# code snippet for BeginInvoke block
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>BeginInvoke</Title>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
@samilkorkmaz
samilkorkmaz / BSTHeight.java
Last active September 17, 2018 13:04
Day 22 of HackerRank 30 Days of Code challenge: Find height of binary search tree
//Day 22 of HackerRank 30 Days of Code challenge: Find height of binary search tree
class BSTHeight {
static int height = -1;
static int maxHeight = -1;
public static int getHeight(Node root){
findMaxHeight(root);
return maxHeight;
}
private static void findMaxHeight(Node node) {
//PWM of sine signal
const n = 12;
const maxAngle_rad = 3 * Math.PI;
const dAngle_rad = maxAngle_rad / n;
var sum = 0;
for (let i = 0; i < n; i++) {
const angle_rad = dAngle_rad * (i + 1);
const sinp1 = 1 + Math.sin(angle_rad); //normalized so that minimum value of sine signal is between [0, 2]
const dutyCyle = sinp1 / 2; //PWM duty cycle
//sum += sinp1 * 2 * Math.PI / n;