Skip to content

Instantly share code, notes, and snippets.

@ishikawash
ishikawash / fibo_num_sequence.py
Created June 26, 2021 02:59
Fibonacci number calculation with Python generator and QTimer.
import sys
import enum
from PySide2 import QtCore
from PySide2.QtWidgets import QApplication, QWidget, QMainWindow, QLabel, QPushButton, QVBoxLayout
def fibo():
a = 0
b = 1
while True:
c = a + b
@ishikawash
ishikawash / window_activation.py
Created May 11, 2021 12:52
Activate window by process ID in Python
# ref: https://sjohannes.wordpress.com/tag/win32/
from __future__ import print_function
import ctypes
from ctypes import windll
import sys
Win32 = windll.user32
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_int, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
@ishikawash
ishikawash / nuxi-problem.cpp
Created August 26, 2020 03:56
The NUXI Problem
#include <iostream>
int main()
{
char text[] = { 'U', 'N', 'I', 'X' };
uint16_t* p = reinterpret_cast<uint16_t*>(text);
for (int i = 0; i < sizeof(text)/sizeof(uint16_t); i++)
{
uint16_t a = *p;
@ishikawash
ishikawash / out.log
Created September 9, 2014 15:16
toxiclibs: Quaternion error
{axis: [0.0,0.7078125,0.0], w: 0.70781255}
{axis: [0.0,-0.70922744,0.0], w: 0.7064004}
@ishikawash
ishikawash / stripe.glsl
Created August 24, 2014 00:52
Stripe shader
#version 120
uniform float rows;
uniform float cols;
void main()
{
int x = int(floor(gl_TexCoord[0].x * cols));
int y = int(floor(gl_TexCoord[0].y * rows));
if (mod(x + y, 2) == 0) {
@ishikawash
ishikawash / demo.pde
Created July 14, 2014 15:37
Basic shader demo with Processing
PShader sh;
PShader f;
PShape square;
PGraphics canvas;
void setup() {
size(640, 480, P3D);
canvas = createGraphics(width, height, P3D);
@ishikawash
ishikawash / fog.vs
Created March 30, 2014 15:15
Fog effect
#version 120
struct Fog {
float start;
float density;
vec3 color;
};
uniform Fog fog;
@ishikawash
ishikawash / pin-hole.fs
Created January 7, 2014 16:18
Pin-Hole like effect
// fragment shader
uniform sampler2D tex;
uniform vec2 viewport;
uniform vec2 origin;
uniform float radius;
uniform float attenuation;
uniform vec3 background_color;
void main()
{
@ishikawash
ishikawash / box.fs
Created January 5, 2014 05:36
Instanced rendering demo using openFrameworks Part 2. The shader program use vertex attributes instead of uniform variables.
#version 120
uniform vec3 light_direction;
varying vec3 vertex_normal;
varying vec3 vertex_color;
void main(void) {
vec3 N = normalize(vertex_normal);
vec3 L = normalize(light_direction);
@ishikawash
ishikawash / box.fs
Created December 19, 2013 12:22
Instanced rendering demo using openFrameworks.
#version 120
uniform vec3 light_direction;
varying vec3 vertex_normal;
varying vec3 vertex_color;
void main(void) {
vec3 N = normalize(vertex_normal);
vec3 L = normalize(light_direction);