Skip to content

Instantly share code, notes, and snippets.

View peterwillcn's full-sized avatar
📡
011010001000100010101010101

open source peterwillcn

📡
011010001000100010101010101
View GitHub Profile
@peterwillcn
peterwillcn / Dockerfile
Created November 17, 2017 10:49 — forked from mhubig/Dockerfile
Alpine Linux based cronjob runner
FROM alpine:latest
RUN apk add --update php python py-pip mysql-client \
&& pip install awscli \
&& rm -rf /var/cache/apk/*
RUN touch crontab.tmp \
&& echo '* */6 * * * /usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run' > crontab.tmp \
&& echo '0 2 * * * /usr/bin/sql_backup' >> crontab.tmp \
&& crontab crontab.tmp \
@peterwillcn
peterwillcn / install_start_stop_daemon.sh
Created April 9, 2018 10:05 — forked from yuuichi-fujioka/install_start_stop_daemon.sh
install start-stop-daemon to centos, fedora, redhat.
#!/bin/bash
cd /usr/local/src
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
tar zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps/sys-utils/start-stop-daemon-IR1_9_18-2
gcc start-stop-daemon.c -o start-stop-daemon
cp start-stop-daemon /usr/sbin/
# Use the high-colour menu system. This file, and the low-colour 'menu.c32'
# version, are provided by the syslinux package and can be found in the
# '/var/lib/tftpboot' directory. Copy it to '/var/lib/tftpboot'.
UI vesamenu.c32
# Time out and use the default menu option. Defined as tenths of a second.
TIMEOUT 2600
# Prompt the user. Set to '1' to automatically choose the default option. This
# is really meant for files matched to MAC addresses.
@peterwillcn
peterwillcn / install_elixir.md
Created July 26, 2018 13:17 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

@peterwillcn
peterwillcn / cool_gpu2.sh
Created August 31, 2018 05:10 — forked from squadbox/cool_gpu2.sh
A script to control Nvidia GPU fan speed on headless (non-X) linux nodes
#!/bin/bash
# cool_gpu2.sh This script will enable or disable fixed gpu fan speed
#
# Description: A script to control GPU fan speed on headless (non-X) linux nodes
# Original Script by Axel Kohlmeyer <akohlmey@gmail.com>
# https://sites.google.com/site/akohlmey/random-hacks/nvidia-gpu-coolness
#
# Modified for newer drivers and removed old work-arounds
@peterwillcn
peterwillcn / htpasswd.py
Created June 12, 2019 09:56 — forked from eculver/htpasswd.py
htpasswd script in python (no need to install apache utils)
#!/usr/local/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
#!/bin/bash
: << '#__REM__'
指定さたライブラリをiOS用にフルオートで作成します。ダウンロード、複数のアーキテクチャのビルドも自動的に行います。デフォルトではi386、x86_64、armv7、armv7s、arm64のアーキテクチャを作成します。
Create a full-auto to iOS for the library specified. I do also builds the architecture download, more than one. Create architecture i386, x86_64, armv7, armv7s, arm64 by default.
#__REM__
TARGET_VERSION="1.3.1"

MySQL Download URL

https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

Open the terminal and follow along:

  • Uninstall any existing version of MySQL
sudo rm /var/lib/mysql/ -R
@peterwillcn
peterwillcn / change.rb
Created April 26, 2020 14:23
Example of dynamic programming in Ruby
INFINITY = 1.0/0
@changes = {}
@coins = [1, 3, 4]
def change(target_value)
return 0 if target_value == 0
return INFINITY if target_value < 0
@changes[target_value] ||= @coins.map do |coin|
change(target_value - coin) + 1
@peterwillcn
peterwillcn / server.ex
Created August 11, 2020 16:37 — forked from adnils/server.ex
Elixir TCP echo server
defmodule Echo.Server do
def start(port) do
tcp_options = [:binary, {:packet, 0}, {:active, false}]
{:ok, socket} = :gen_tcp.listen(port, tcp_options)
listen(socket)
end
defp listen(socket) do
{:ok, conn} = :gen_tcp.accept(socket)
spawn(fn -> recv(conn) end)