Skip to content

Instantly share code, notes, and snippets.

@tkshnwesper
tkshnwesper / auto_restart.sh
Last active January 9, 2022 07:58
Script to automatically restart a system if there's a problem in connecting to the internet
#!/bin/bash
HOSTNAME=1.1.1.1
TIMEOUT=150
TEST_INTERVAL=60
ping_host() {
ping -c1 "$HOSTNAME" &> /dev/null
}
@tkshnwesper
tkshnwesper / byobuCommands
Created August 21, 2018 16:06 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
@tkshnwesper
tkshnwesper / setup.sh
Last active March 11, 2018 15:53
Raspberry Pi Setup
sudo apt install dnsmasq hostapd -y
sudo echo "denyinterfaces wlan0" | sudo tee -a /etc/dhcpcd.conf
sudo tee /etc/network/interfaces.d/wlan0 << EOM
allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
@tkshnwesper
tkshnwesper / README.md
Last active January 5, 2018 18:15
How to setup Gradle on an Existing Intellij Project (Pathashala)

This tutorial assumes that you have

  1. /src/main as your sources folder
  2. /src/test as your test folder
  3. /src/resources as your resources folder

(Even you if don't, it's alright, read on. You'll just have to modify the gradle file a bit)

Install Gradle

You need to install the latest version locally.

@tkshnwesper
tkshnwesper / build.gradle
Created January 5, 2018 17:33
Pathashala Gradle Boilerplate (with JUnit5 and Mockito 2.+)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1'
}
}
apply plugin: 'java'
@tkshnwesper
tkshnwesper / com.py
Created June 9, 2017 12:54
Python script that outputs the musical notes of the sounds that it captures through its mic
import alsaaudio
import numpy as np
from scipy.signal import fftconvolve, kaiser
from matplotlib.mlab import find
import math
# import serial
# ser = serial.Serial('/dev/ttyACM0', baudrate=9600, timeout=0)
fqsdict = {
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 180;
client_max_body_size 0;
sendfile on;
tcp_nodelay on;
gzip off;
upstream droppy {

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@tkshnwesper
tkshnwesper / sql.kt
Created January 22, 2017 16:53
Creating an SQL keyword that does not exist in Anko
db?.createTable("tablename", true,
"id" to INTEGER + PRIMARY_KEY,
"name" to TEXT,
"base" to TEXT,
"lastRead" to object : SqlType {
override val modifier: String?
get() = null
override val name: String
get() = "DATETIME"
}
@tkshnwesper
tkshnwesper / op.kt
Created December 25, 2016 20:23
An example of how to use doAsyncResult in Anko
class PopularActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
listView {
id = ViewID.ID_POPULAR_LIST
// This task will happen asynchronously in a separate thread (so you can perform network operations)