Posts

Showing posts from February, 2019

[p5.js] What is p5.js

Image
Get Started This page walks you through setting up a p5.js project and making your first sketch. If you'd like to start with the new  p5.js Web Editor , you can jump down to  Your First Sketch . Download and File Setup The easiest way to start is by using the empty example that comes with the p5.js complete  download. If you look in index.html, you'll notice that it links to the file p5.js. If you would like to use the minified version (compressed for faster page loading), change the link to p5.min.js. A sample HTML page might look like this: < html > < head > < script src = " https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js " > </ script > < script src = " sketch.js " > </ script > </ head > < body > </ body > </ html > You can also start with this template from  codepen . Your First Sketch Processing users may want to check out the  Processi...

[p5.js] Hello p5.js

Source Code: <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script> <script> function setup() { var canvas = createCanvas(640, 480); canvas.parent('sketch-canvas'); } function draw() { if (mouseIsPressed) { fill(0); } else { fill(255); } ellipse(mouseX, mouseY, 80, 80); } </script>

[C] How to use file IO with C

Image
#include<unistd.h> #include<fcntl.h> #include<string.h> const int BUFF_SIZE = 128; int main(){ char *error_msg = "This is Error\n"; char buff[BUFF_SIZE]; int file; ssize_t rd_size; creat("name.txt", 0644); file = open("name.txt", O_RDWR); if(file == -1){ write(1, error_msg, strlen(error_msg)); }else{ while(1){ rd_size = read(0, buff, BUFF_SIZE); if(strstr(buff, ":wq")){ break; } write(file, buff, rd_size); } lseek(file, 0, SEEK_SET); char *temp = "-------------------------\n"; write(1, temp, strlen(temp)); while(0 < (rd_size = read(file, buff, BUFF_SIZE-1))){ buff[rd_size] = '\0'; write(1, buff, strlen(buff)); } close(file); } return 0; }

[C] How to use fork with C

Image
#include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { char *name = argv[0]; int child_pid = fork(); if (child_pid == 0) { printf("Child of %s is %d\n", name, child_pid); return 0; } else { printf("My child is %d\n", child_pid); return 0; } return 0; }

[C] How to allocate memory with C

Image
#include<stdio.h> #include<stdlib.h> int function1(int, int); int a; int main(int argc, char *argv[]) { int b = 1, c = 2; int *sum = NULL; sum = (int*)malloc(sizeof(int)); *sum = function1(b, c); printf("%d\n", *sum); free(sum); system("read -n 1 -s -p \"Press any key to continue...\""); return 0; } int function1(int num1, int num2) { int s; s = num1 + num2; return s; }

[C] How to print "Hello World" by System Call with C

Image
/* /* ssize_t write(int filedes, const void *buf, size_t nbytes); 0 : STDIN_FILENO 1 : STDOUT_FILENO 2 : STDERR_FILENO */ #include <string.h> #include <unistd.h> int main(int argc, char *argv[]){ int std = 1; char str[] = "Hello World\n"; write(std, str, strlen(str)); return 0; }

[C] How to use for loop with C

Image
#include<stdio.h> int main(int argc, char *argv[]){ int result = 0; int i = 0; for(i = 1; i <= 1000; i++){ result += i; } printf("sum of 1 to 1000 : %d\n", result); return 0; }

[C] How to print "Hello World" with C

Image
#include<stdio.h> int main(int argc, char *argv[]){ printf("Hello World\n"); return 0; }

[OpenCV] How to trace objects with gocv?

Image
How to trace objects with gocv? 1. install OpenCV for gocv. [ how to install ] 2. run gocv code [ github ] run command :  $ go run gocv_example02.go 0 ../../data/lbpcascades/lbpcascade_frontalface.xml   3. show camera

[OpenCV] How to start the camera with gocv?

Image
How to start the camera with gocv? 1. install OpenCV for gocv. [ how to install ] 2. run gocv code [ github ] package main import ( "gocv.io/x/gocv" ) func main () {      webcam , _ := gocv. VideoCaptureDevice ( 0 )      window := gocv. NewWindow ( "Hello" )      img := gocv. NewMat ()      for {         webcam. Read (&img)         window. IMShow (img)         window. WaitKey ( 1 )     } } 3. show camera

[Go] gotatic with echo web framework made by kwonsukmin

Image
Gotatic: This is a simple go web server made by kwonsukmin. I think it helps you to learn 'go'. [source]  http://ilovebambi.com/221290591255?Redirect=Log&from=postView Source Code: [github]  https://github.com/hermes7308/gotatic

[Beelinguapp] The king and stupid monkey

Story  A long time ago, a king lived in a palace near a jungle. From the palace, he could hear the chattering of the monkey. Looking at the monkey made him happy. One day he ordered his hunters to use nets to capture one of the monkeys and bring it back to the palace. He decided to keep the monkeys as a pet. The king's advisor warned him that keeping the monkey in the palace was not a good idea. "Monkeys are wild animals and can be dangerous," the advisor told him. But, the king was in charge. He gave the orders. He did not have to take the advice of anyone. He was the king. He knew better than his advisors. "This is my royal Monkey," he told the palace staff. "It may go wherever it wants in the palace and may do what it wishes." But, the monkey was not trained. It did many foolish things in the palace. It made many messes. But no one stopped it. They did not want to go against the wishes of the king. The monkey went everywhere it wanted, including...

[Java] Tetris made with pure java

Image
Tetris made with pure java This T etris game  is made pure java. I made this when I was in university student. This is easy and simple to make. If you want to make this program, I can give you my code and I want you to make this better.

[Java] Screen sharing program made with pure Java

Image
Screen sharing program made with pure Java  This is made pure java. Macbook screen shared in windows desktop. I made this when I was in university student. This is easy and simple to make. If you want to make this program, I can give you my code and I want you to make this better.

[Terminal] Beautiful console

Image
How to do? .bashrc orange=$(tput setaf 166); yellow=$(tput setaf 228); green=$(tput setaf 71); bold=$(tput bold); reset=$(tput sgr0); PS1="\[${bold}\]\n"; PS1+="\[${orange}\]\u";             # username PS1+="\[${white}\]@"; PS1+="\[${yellow}\]\h";             # host PS1+="\[${white}\]:"; PS1+="\[${green}\]\w";               # working directory PS1+="\n"; PS1+="\[${white}\]\$ \[${reset}\]"; # '$' (and reset color) export PS1; export CLICOLOR=1 alias ls='ls -GFh' .bash_profile source ~/.bashrc

[OpenCV] How to set up gocv

This page has information on how to install and use GoCV on macOS. Installing Install the GoCV package: go get -u -d gocv.io/x/gocv You can install OpenCV 4.0.0 using Homebrew. If you already have an earlier version of OpenCV (3.4.x) installed, you should probably remove it before installing the new version: brew uninstall opencv You can then install OpenCV 4.0.0: brew install hybridgroup /tools/ opencv This new Homebrew recipe will install only OpenCV 4.0.0 without all of the Python dependencies. pkgconfig Installation pkg-config is used to determine the correct flags for compiling and linking OpenCV. You can install it by using Homebrew: brew install pkgconfig How to build/run code Once you have installed OpenCV, you should be able to build or run any of the command examples: go run ./ cmd /version/main.go The version program should output the following: gocv version : 0 .18 .0 opencv lib version : 4 .0 .0 Cache builds If you are running a ve...

[OpenCV] What is gocv?

Image
GoCV           The GoCV package provides Go language bindings for the  OpenCV 4  computer vision library. The GoCV package supports the latest releases of Go and OpenCV (v4.0.0) on Linux, macOS, and Windows. We intend to make the Go language a "first-class" client compatible with the latest developments in the OpenCV ecosystem. GoCV also supports  Intel OpenVINO . Check out the  OpenVINO README  for more info on how to use GoCV with the Intel OpenVINO toolkit. How to use Hello, video This example opens a video capture device using device "0", reads frames, and shows the video in a GUI window: package main import ( " gocv.io/x/gocv " ) func main () { webcam , _ := gocv. OpenVideoCapture ( 0 ) window := gocv. NewWindow ( " Hello " ) img := gocv. NewMat () for { webcam. Read (&img) window. IMShow (img) window. WaitKey ( 1 ) } } Face detect This is a more complete example that opens a v...