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 / [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 ""
# 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")
public static boolean isInString(String haystack, String needle) {
return (haystack.indexOf(needle) >= 0);
}
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 = {
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) {
-----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
@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
@TwiN
TwiN / ActivityEventListener.md
Created October 24, 2017 14:48 — forked from blackcj/ActivityEventListener.md
Demonstrates how to call a function in the parent Activity from within a Fragment.

Step 1: Add any functions you want to call into the interface (EventListener).

Step 2: Implement those functions in your MainActivity.

Step 3: Create the listener in your Fragment and attach it to the Activity.

Step 4: Call any functions on the listener.

@TwiN
TwiN / WebConfiguration.java
Created December 17, 2017 21:51
Link a React app using React-Router and bundled with Webpack to a Spring Boot app
package org.twinnation.site;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
public class WebConfiguration {
@TwiN
TwiN / package.json
Created December 19, 2017 21:04
My webpack configuration (+ package.json)
{
"name": "twinnation",
"author": "TwiN",
"description": "TwiNNatioN",
"version": "0.7.5",
"license": "MIT",
"main": "src/App.js",
"scripts": {
"start-webpack": "webpack-dev-server --port 80 --hot --progress --colors",
"build-webpack": "webpack --config webpack.config.js -p",