Skip to content

Instantly share code, notes, and snippets.

@tenthree
tenthree / vps-ubuntu-server-16.04-for-beginner.md
Last active January 14, 2023 09:38
vps ubuntu server 16.04 for beginner

Set up VPS server for beginner

use Ubuntu 16.04/18.04 (lsb_release -a)

Get Started

  • Update packages and system

    • sudo apt update
    • sudo apt upgrade

    If you do encounter problem like this, "A new version of configuration file/etc/default/grub is available,but the version installed currently has been locally modified".

> You can choose "install the package maintainer's version."

@tenthree
tenthree / ubuntu-useful-commands.md
Last active December 18, 2017 10:05
ubuntu useful commands

Ubuntu useful commands

  • list users

    compgen -u or cut -d ":" -f 1 /etc/passwd

  • list groups > compgen -g
@echo off
SET CMDER_ROOT=C:\PortableApps\cmder_mini
SET ConEmuDir=C:\PortableApps\cmder_mini\vendor\conemu-maximus5
SET CMDER_INIT_BAT=C:\PortableApps\cmder_mini\vendor\init.bat
C:\Windows\sysnative\cmd.exe /k "%CMDER_INIT_BAT%"
@tenthree
tenthree / insetion_sort.rs
Created September 4, 2018 07:36
insertion sort in rust
extern crate rand;
use rand::prelude::*;
fn main() {
const LEN: usize = 10;
let mut arr: [i32; LEN] = [0; LEN];
let mut rng = thread_rng();
for index in 0..LEN {
arr[index] = rng.gen_range(0, 101)
@tenthree
tenthree / impl_display_and_debug_traits.rs
Last active September 5, 2018 09:47
implement Display and Debug Trait with generics struct in Rust
use std::fmt;
// #[derive(Debug)]
struct Point<T> {
x: T,
y: T,
}
impl <T> fmt::Debug for Point<T> where T: fmt::Display {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@tenthree
tenthree / simple_rust_server.rs
Created September 5, 2018 17:21
simple rust server
use std::fs;
use std::io::{ Read, Write };
use std::net::{ TcpListener, TcpStream};
fn main() {
let server: TcpListener = TcpListener::bind("127.0.0.1:8080").unwrap();
for stream in server.incoming() {
match stream {
Ok(mut stream) => {
router(stream)
@tenthree
tenthree / hi.go
Created September 11, 2018 08:57
radio stream generator in go
package hi
import (
"crypto/md5"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strconv"
@tenthree
tenthree / PhotoCompared.vue
Last active May 28, 2019 17:14
Vue.js PhotoCompared component
<template>
<div class="photo-compared" :class="className" @mousedown="onPointDown" @touchstart="onPointDown">
<div class="photo-compared__frame" :style="frameStyle"></div>
<div class="photo-compared__before" :style="beforeStyle"></div>
<div class="photo-compared__after" :style="afterStyle"></div>
<div class="photo-compared__handler" :style="handlerStyle"></div>
</div>
</template>
<script>
@tenthree
tenthree / fake-images.js
Created June 24, 2019 08:22
fake-images middleware for local development
module.exports = function () {
//
// [ express middleware ]
// Generate a /fake/images route for testing images source
//
// images service origin:
// - PICSUM(https://picsum.photos)
// Created by David Marby & Nijiko Yonskai
// Having trouble? Poke @DMarby on Twitter
// Images from unsplash
@tenthree
tenthree / backup.js
Created June 24, 2019 08:27
project backup script
const fs = require('fs')
const path = require('path')
const ora = require('ora')
const chalk = require('chalk')
const mkdirp = require('mkdirp')
const globby = require('globby')
const archiver = require('archiver')
const clear = require('clear')
const pkg = require('./package.json')