Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshihiko Arai araemon

View GitHub Profile
View websocket-sever.py
from websocket_server import WebsocketServer
def sendMessage(client, server):
server.send_message_to_all("Hello world! This is Raspberry Pi!")
def receivedMessage(client, server, message):
print message
server.send_message(client, "recived message: " + message)
server = WebsocketServer(5555, host="192.168.100.136")
View websocket-client.html
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js">
</script>
<script>
$(function () {
var ws = new WebSocket("ws://192.168.100.136:5555/");
ws.onmessage = function (message) {
document.getElementById("recived").innerHTML = message.data;
View websocket-sever.py
from websocket_server import WebsocketServer
def sendMessage(client, server):
server.send_message_to_all("Hello world! This is Raspberry Pi!")
server = WebsocketServer(5555, host="192.168.100.136")
server.set_fn_new_client(sendMessage)
server.run_forever()
View WebSocket-client.py
# -*- coding: utf-8 -*-
import time
import os
import base64
import socket
import struct
import array
try:
import thread
except ImportError:
View debugMode.kt
if (BuildConfig.DEBUG) {
/* ここにデバッグ時のみ実行したい処理を書く */
}
View admob.kt
val configuration = RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("Test Device Id")).build()
MobileAds.setRequestConfiguration(configuration)
View admob.kt
adView.adListener = object: AdListener() {
override fun onAdFailedToLoad(errorCode : Int) {
// Code to be executed when an ad request fails.
Log.d("Mopi","onAdFailedToLoad(errorCode : Int)" + errorCode)
}
...
}
View isPad.swift
let h = (UIDevice.current.userInterfaceIdiom == .pad) ? 90 : 50
View debug.swift
#if DEBUG
print("デバッグ時のみ実行")
#else
print("リリース時のみ実行")
#endif
View singleton.swift
class Hoge {
static let shared = Hoge()
private override init() {
super.init()
}
func doSomething() {
...
You can’t perform that action at this time.