Skip to content

Instantly share code, notes, and snippets.

@bbrother92
bbrother92 / 0_reuse_code.js
Created November 26, 2016 06:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bbrother92
bbrother92 / factorial.java
Created December 17, 2016 00:55
tail call
public class Fac {
public static void main(String[] args) {
System.out.println(fac(6, 1));
}
static int fac (int n,int acc) {
return (n==0)? acc:fac(n-1,acc*n);
}
}
@bbrother92
bbrother92 / Iterable.java
Last active December 19, 2016 15:40
#collections
public class Main {
public static void main(String... args) {
Box bx = new Box();
for (Human o : bx) {
System.out.println(o);
}
}
}
//Generate JavaDoc -> "Other command line argument" "-encoding UTF-8 -docencoding UTF-8 -charset UTF-8"
def foo(bar=[]): # bar is optional and defaults to [] if not specified
... bar.append("baz") # but this line could be problematic, as we'll see...
... return bar
#=========
print dir(math)
print type(2.)
duck_index =animals.index("duck") # Use index() to find "duck"
animals = animals.insert(duck_index,"cobra")
square_list.sort()
#!/usr/bin/env python
"""Basic Python Cheat Sheet by Filip Kral on 2015/02/16"""
"""
Python is a cross-platform, interpreted, object-oriented programming language.
That means you can run it on Linux, Windows, Mac, and other platforms,
you don't need to compile your code to execute it because it is compiled on
the fly, and you can use classes and objects.
import java.lang.annotation.*;
public class TestClass {
@About
public void mtd () throws NoSuchMethodException {
Class cl = TestClass.class;
Annotation an = cl.getMethod("mtd", null).getAnnotation(About.class);
System.out.println(cl.getMethod("mtd", null).getName());
System.out.println(cl.getMethod("mtd", null).getReturnType());
@bbrother92
bbrother92 / SeleniumNotes.md
Last active June 28, 2017 16:37
Selenium cheatsheet #java
@bbrother92
bbrother92 / JavaCheatSheet.md
Last active July 8, 2024 03:21
#cheatsheet #Java

Basic numeric types

char \u0000 16B (65535)
byte (-128 127) 
short 2B   (-32768 до 32767)
int 4B (-2147483648 до 2147483647)
long 64B (+- 9*10^18)
0154 octal
0b01101100 binary
3_000_000_000L long
@bbrother92
bbrother92 / grep.md
Last active June 27, 2022 11:29
#bash #regex #cheatsheet #grep

GREP Options

--max-count=number of matches before stopping search
--exclude=*.txt  with -r option

Note: Lookahead and lookbehind are Perl-style regular expression elements, so you'd have to use Perl directly, or GNU grep with the -P option, which then interprets Perl regex.

grep -o pattern file.txt **shows only the matched string** 
grep -bn pattern file.txt **shows row and col**  
grep -v pattern file.txt **inversion**