Start
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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 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); | |
} | |
} |
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 Main { | |
public static void main(String... args) { | |
Box bx = new Box(); | |
for (Human o : bx) { | |
System.out.println(o); | |
} | |
} | |
} |
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
//Generate JavaDoc -> "Other command line argument" "-encoding UTF-8 -docencoding UTF-8 -charset UTF-8" | |
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
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() |
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
#!/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. |
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
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()); |
--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**
OlderNewer