Skip to content

Instantly share code, notes, and snippets.

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
int main()
{
char directory[_MAX_PATH + 1];
char filename[_MAX_PATH + 1];

How not to rm yourself

Copied from https://github.com/sindresorhus/guides/blob/master/how-not-to-rm-yourself.md

The rm command is inherently dangerous and should not be used directly. It can at worst let you accidentally remove everything. Here's how you can protect you from yourself.

Use trash

The trash command-line tool will move stuff to the trash instead of permanently deleting it. You should not alias rm to trash as it will break external scripts relaying on the behavior of rm. Instead use it directly: trash image.jpg.

@vbuterin2
vbuterin2 / tcp_speed.sh
Created July 5, 2020 13:06 — forked from SpeedMe/tcp_speed.sh
tcp_speed
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: CentOS 6+,Debian7+,Ubuntu12+
# Description: BBR+BBR魔改版+Lotserver
# Version: 1.0.6
# Author: 千影
# Blog: https://www.94ish.me/
@vbuterin2
vbuterin2 / lambda.kt
Created June 28, 2020 14:56
lambda expression kotlin
val sum = {number1:Int, number2:Int -> number1 + number2}
fun main() {
val addNumbers = sum(3, 4)
println("addNumbers: $addNumbers")
println("List of numbers")
val listOfNumbers = listOf(10,15,22,34,80)
listOfNumbers.forEach{number -> println(number) }
@vbuterin2
vbuterin2 / simpleif.kt
Created June 28, 2020 14:47
Simple If
fun main() {
println("Enter your grade: ")
val grade = readLine()!!.toInt()
if (grade >= 90) {
println("A")
}
if (grade in 80..89) {
println("B")
@vbuterin2
vbuterin2 / swap_number.kt
Created June 28, 2020 14:38
Swap number
fun main() {
print("Enter number 1: ")
var number1 = readLine()!!.toInt()
print("Enter number 2: ")
var number2 = readLine()!!.toInt()
val temp = number1
number1 = number2
@vbuterin2
vbuterin2 / HashMap.kt
Created June 28, 2020 14:32
How to use HashMap and LinkedList
import java.util.*;
import kotlin.collections.HashMap
fun main() {
val listOfUsers = HashMap<String, LinkedList<String>>();
while (true) {
print("Enter your name or quit: ")
val name = readLine()!!.toString()
if (name == "quit") {
@vbuterin2
vbuterin2 / when.kt
Created June 28, 2020 11:33
在kotlin中使用when语句
fun main() {
val isMarried = true
val GPA = 4.0
val isQualified = if (isMarried && GPA >= 3.8) 1 else 0
println(isQualified)
val isGood = when(GPA) {
@vbuterin2
vbuterin2 / mutablelist.kt
Created June 28, 2020 10:40
Mutable List vs Immuatable List
fun main(args: Array<String>) {
val listImmutable = listOf("cdkfox", "bzp")
for (name in listImmutable) {
println(name)
}
// mutable
var listMutable = mutableListOf("cdkfox", "bzp")
listMutable[0] = "cdkfox"
class UserAdmins<T>(credit:T) {
init {
println(credit)
}
}
fun <T> display(process: T) {
println(process)
}