Skip to content

Instantly share code, notes, and snippets.

View TwiN's full-sized avatar
Extremely busy

TwiN

Extremely busy
View GitHub Profile
@TwiN
TwiN / _00-MASTER_SCRIPT.sql
Last active April 21, 2017 18:25
TP3_SQL_SCRIPTS
-- Script that runs the other scripts in the proper order
-- Reset the value of scripts_path in case it was already set
UNDEFINE scripts_path
-- ask the user to set the scripts path
PROMPT Set the path to the directory in which this file currently is.
PROMPT (ex: if the path to this script is C:\SQL\_MASTER_SCRIPT.sql,
PROMPT then the path should be C:\SQL\ )
PROMPT
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBFhwhlABCADbZSl4xWH4E/OlXKQXpFBN5QRG8UPbZlwtKFhVApRsL/bcJmsG
NxrSmbtB/zR9llVF9c1TqWl8OTW0uikwNfoJ2mFshBI69BFL2uz20G//SPKY0Pfr
XWCnXZR/rwy2WB7XjfbKFSRBlHDAZ8nm/UAlV+xmKGFbE21I2YmeeetY5mUobCLJ
RrUqBm9XVONjEAhUlnPECHgLb+f6VfFWE480qDhHK2l2Nq8893GCkCciq+HGAKJH
TGSdxGOYfsRIkvwM0Y5XsSlmBkMt+ZplLqQuvUpudyv4PU9iartzjFGrBrRb8F5y
Im3yey8SYLbx2LaFxoIBbTWy/y4EILndZOzLABEBAAG0JENocmlzIEMtVCA8Y2hy
aXN0aWFuLWN0QGhvdG1haWwuY29tPokBNwQTAQoAIQUCWHCGUAIbAwULCQgHAwUV
CgkICwUWAgMBAAIeAQIXgAAKCRA2RjO/yYA4/vUkCACUaz6INeNSDJS1DSXnJFQj
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
/**
* Converts a png file to a jpg file
* WARNING: JPG does not support transparency! It will be replaced by white.
* @param imgName Name of the image file
*/
public void png2jpg(String imgName) {
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
public class CalendarGenerator {
public static final int[] MONTH_DAYS = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
public static final String[] MONTH_NAMES = {
public static boolean isInString(String haystack, String needle) {
return (haystack.indexOf(needle) >= 0);
}
# overwrite fname
def writeInFile(fname, data):
fhandler = open(fname, "w")
fhandler.write(data)
fhandler.close()
# append to new line in fname
def writeInFile(fname, data):
fhandler = open(fname, "a")
@TwiN
TwiN / [PYTHON]getBetween(string, first, last).py
Created July 16, 2016 22:39
A python function that gets a substring in a string between two strings.
def getBetween(s, first, last):
try:
start = s.index(first ) + len(first)
end = s.index(last, start)
return s[start:end]
except ValueError:
return ""
@TwiN
TwiN / [PYTHON]file_get_contents(URL).py
Last active August 22, 2022 22:44
Python equivalent of PHP's file_get_contents on websites (NOT LOCAL FILES)
import urllib2,cookielib
'''
Function that returns the source from the target url
@param url
'''
def file_get_contents(url):
url = str(url).replace(" ", "+") # just in case, no space in url
hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
for i in range(101):
if i==0: continue
if (i%3==0) ^ (i%5==0):
print "fizz" if i%3==0 else "buzz"
elif i%3==0:
print "fizzbuzz"
else:
print i
public static boolean isInList(String[] myList, String element) {
for(String s: myList) {
if (s.equals(element)) { return true; }
}
return false;
}
public static boolean isInList(char[] myList, char element) {
for(char c: myList) {
if (c == element) { return true; }
}