Skip to content

Instantly share code, notes, and snippets.

View hisasann's full-sized avatar
🔖
I aspire to become a bookseller.

Yoshiyuki Hisamatsu hisasann

🔖
I aspire to become a bookseller.
View GitHub Profile
const log = require('electron-log-rotate');
module.exports = {
// path.resolve([from ...], to)
resolve: function resolve() {
var resolvedDevice = '';
var resolvedTail = '';
var resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1; i--) {
@hisasann
hisasann / BrightnessController.cs
Created July 31, 2017 08:54
windows上で輝度を変更するコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management;
namespace DeviceManager.Brightness
{
class BrightnessController
@hisasann
hisasann / VolumeController.cs
Last active October 22, 2017 05:31
windows上でボリュームを変更するコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CoreAudioApi;
namespace DeviceManager.Volume
{
class VolumeController
@hisasann
hisasann / hello.cc
Created February 15, 2017 10:42
node native addon using nan
#include <nan.h>
void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(Nan::New("world").ToLocalChecked());
}
void Init(v8::Local<v8::Object> exports) {
exports->Set(Nan::New("hello").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(Method)->GetFunction());
}
@hisasann
hisasann / hello.cc
Created February 15, 2017 10:41
node native addon using only node gyp
#include <node.h>
#include <v8.h>
void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, "world"));
}
void init(v8::Local<v8::Object> exports) {
@hisasann
hisasann / canHookToPrimitive.js
Created February 10, 2017 07:17
I can hook ToPrimitive method!
var a = {
x: 1,
[Symbol.toPrimitive]: function(type) {
console.log('called toPrimitive, type: ', type);
return this.x;
}
};
Number(a);
let mainWindow = null;
// Create the browser window.
if (process.env.NODE_ENV === 'development') {
mainWindow = new BrowserWindow({
width: 1024,
height: 728,
transparent: false,
show: false,
frame: true,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
canvas {
width: 500px;
height: 500px;
}
@hisasann
hisasann / websocket-native-sample.js
Created August 29, 2016 06:00
すごくシンプルな WebSocket サンプル
var socket = new WebSocket('ws://127.0.0.1:8080/websocket');
var socket.onmessage = onmessage;
var socket.onopen = onopen;
var socket.onclose = onclose;
function onmessage(event) {
console.log('from-server: ', event.data);
}
function onopen() {
@hisasann
hisasann / es-next-async-await-ex.js
Created June 8, 2016 04:50
async / await を使ったパターン
'use strict';
import 'babel-regenerator-runtime';
// require('babel-polyfill'); // おまじない
//require('regenerator').runtime();
console.log('main: start');
main().then(function (val) {
console.log('main: finish:', val);
});