Skip to content

Instantly share code, notes, and snippets.

View makerj's full-sized avatar
💗

Junhee Lee makerj

💗
View GitHub Profile

Laptop running as a server

I am running an old Dell Laptop as a server with Ubuntu 18.04 on it. Installing Ubuntu on the system was straight forward, but at a certain point you want to close the lid of the laptop. This puts your laptop in sleep, which for a server is not the intended result.

Disable Sleep on Lid Close

Debians Suspend Wiki page had the right solution for this

"""
Maximize currently focused window to vertically half of the screen
Win+Pgup hotkey performs top-half maximization
Win+Pgdn hotkey performs bottom-half maximization
NOTE: This script requires keyboard and pywin32 packages
Tested on my Microsoft Windows 10 PC with dual-monitor
"""
import keyboard
@makerj
makerj / distribution.c
Last active August 4, 2018 16:17
Cumulative Standardized Normal Distribution
// https://home.ubalt.edu/ntsbarsh/Business-stat/StatistialTables.pdf
// Cumulative Standardized Normal Distribution
//
// Values of z of particular importance:
// z A(z)
// 1.645 0.9500 Lower limit of right 5% tail
// 1.960 0.9750 Lower limit of right 2.5% tail
// 2.326 0.9900 Lower limit of right 1% tail
// 2.576 0.9950 Lower limit of right 0.5% tail
// 3.090 0.9990 Lower limit of right 0.1% tail
@makerj
makerj / SWIG C and JAVA.md
Last active March 16, 2018 05:23
SWIG C and JAVA

SWIG C and JAVA

(작성중)

SWIG는 기존에 작성된 C 또는 C++ 라이브러리를 다양한 언어에 포팅하는데 사용되는 도구이다. 이 글에서는 C 라이브러리를 JAVA와 연결하는데 필요한 정보를 정리한다. 이 글에서 C 라이브러리의 이름은 mylib 라고 가정한다.

@makerj
makerj / bash-by-examples.md
Last active October 12, 2018 01:57
Improve bash skills through step by step examples.

Bash by examples

Table of Contents

  • variable
  • input
  • print
  • conditional
  • commandline arguments
  • function
  • array
@makerj
makerj / xmas-tree.c
Created December 25, 2017 08:33
shows xmas tree animation on linux terminal
/*
Copyright (C) 2017 junhee lee
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <sys/ioctl.h>
@makerj
makerj / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created April 9, 2017 05:40 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
// once
struct sigaction sigact, old_sigact;
sigact.sa_handler = handler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_INTERRUPT;
sigaction(SIGALRM, &sigact, &old_sigact) < 0);
// somewhere loop
while(1) {
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "time.h"
#include "sys/types.h"
#include "sys/socket.h"
#include "netinet/in.h"
#define BUF_LEN 8192