This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"github.com/gin-gonic/gin" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"io" | |
"mime/multipart" | |
"net/http" | |
"os" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fibonacci { | |
public static long fibonacci(int n) { | |
if (n <= 1) return n; | |
else return fibonacci(n-1) + fibonacci(n-2); | |
} | |
public static void main(String[] args) { | |
int n = Integer.parseInt(args[0]); | |
for (int i = 1; i <= n; i++) | |
System.out.print(i + ": " + fibonacci(i)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.out.println("CompletableFuture"); | |
Future<String> foo = new CompletableFuture<>(); | |
System.out.println(foo.cancel(true)); | |
System.out.println(foo.cancel(true)); | |
System.out.println("Guava SettableFuture"); | |
foo = SettableFuture.create(); | |
System.out.println(foo.cancel(true)); | |
System.out.println(foo.cancel(true)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sv s /service/* | |
Stops a service immediately (would still start on next boot): | |
# sv d ssh | |
Restarts a service: | |
# sv t ssh | |
# sv i postgresql | |
Reloads a service: | |
# sv h ssh | |
Shows status of a service and it's log service: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#scheduler; list | |
$ atq | |
#add | |
echo wget https://sample.com | at 3:00 PM | |
$ cp /home/sample.txt{,-old} | |
$ ls | |
text_comes_here_1.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#find string in any file for dir/subdir | |
grep -lir 'go api' ./ | |
#useful util for a lof of commands, example: | |
tldr grep | |
tldr find | |
#list of dir | |
grep mkyong -lr /path/folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pstree 32567 | |
pstree -p 32567 | |
pstree -p 32567| perl -ne 'print "$_\n" foreach /\((\d+)\)/g;' | |
pstree -p 32567| perl -ne '`kill -9 $_` foreach /\((\d+)\)/g;' | |
pstree -p 32567| perl -ne 'print "$1\n" while /\((\d+)\)/g;' | |
pstree -p 32567| perl -ne '`kill -9 $1` while /\((\d+)\)/g;' |
NewerOlder