Skip to content

Instantly share code, notes, and snippets.

View fynntimes's full-sized avatar

Fynn fynntimes

View GitHub Profile
@fynntimes
fynntimes / write_ini.php
Created October 18, 2015 15:39
Useful PHP method to write an .ini file.
// This should really be part of the PHP API...
function write_ini_file($assoc_arr, $path, $has_sections = FALSE)
{
$content = "";
if ($has_sections) {
foreach ($assoc_arr as $key => $elem) {
$content .= "[" . $key . "]\n";
foreach ($elem as $key2 => $elem2) {
if (is_array($elem2)) {
for ($i = 0; $i < count($elem2); $i++) {
@fynntimes
fynntimes / GsonFactory.java
Last active March 1, 2016 21:53
GsonFactory for Bukkit
//TODO add your package name here
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.Expose;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
@fynntimes
fynntimes / Chests.java
Last active April 7, 2016 00:18
Chests
CraftChest chest = (CraftChest) block.getState(); //block has to be a chest
try
{
Field inventoryField = chest.getClass().getDeclaredField("chest"); //This gets the CraftChest variable 'chest' which is the TileEntityChest that is stored within it
inventoryField.setAccessible(true); //Allows you to access that field since it's declared as private
TileEntityChest teChest = ((TileEntityChest) inventoryField.get(chest)); //obtains the field and casts it to a TileEntityChest
teChest.a("Name Goes Here"); //The a(String) method sets the title of the chest
}
@fynntimes
fynntimes / FxExperienceSplash.java
Last active April 21, 2016 15:36 — forked from jewelsea/FxExperienceSplash
JavaFX standalone application Splash Page for a great website.
package org.jewelsea.examples.splash;
import javafx.animation.FadeTransition;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;

Keybase proof

I hereby claim:

  • I am SirFaizdat on github.
  • I am sirfaizdat (https://keybase.io/sirfaizdat) on keybase.
  • I have a public key whose fingerprint is 07E9 87D3 6C24 5A55 E5CE 0137 65C5 FDEE 203E EAFD

To claim this, I am signing this object:

// Imports, I just wrote this up quick in Gist
public class Cooldowns extends JavaPlugin {
private Map<UUID, Long> cooldowns = new HashMap<>();
private long cooldownDurationMillis = 3000; // 3 seconds (1000 millis = 1 second)
@Override public void onEnable() {
}

Keybase proof

I hereby claim:

  • I am faizaand on github.
  • I am sirfaizdat (https://keybase.io/sirfaizdat) on keybase.
  • I have a public key whose fingerprint is 07E9 87D3 6C24 5A55 E5CE 0137 65C5 FDEE 203E EAFD

To claim this, I am signing this object:

@fynntimes
fynntimes / Calculator.kt
Created November 11, 2017 21:08
A rudimentary mathematical expression evaluator in Kotlin.
import java.util.*
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
import javax.script.ScriptException
// Instance variables
val engine: ScriptEngine = ScriptEngineManager().getEngineByName("JavaScript")
val jsMathMap = hashMapOf("sin" to "Math.sin", "cos" to "Math.cos", "tan" to "Math.tan", "pi" to "Math.PI")
fun main(args: Array<String>) {
@fynntimes
fynntimes / sim_num25.py
Last active December 1, 2017 01:00
A simple script I threw together quickly to run simple AP Statistics simulations with probability.
# Faizaan Datoo Pd3
# A very simple example of using technology to automate simulations :)
# I /could/ have made it more complicated, but that would defeat the point!
import random
print "Enter a range of digits."
# Get those numbers...
minVal = input("\tYour minimum value: ")
@fynntimes
fynntimes / simulations.py
Last active August 5, 2019 00:32
A general AP Statistics probability simulation script.
# Faizaan Datoo Pd3
# A very simple example of using technology to automate simulations :)
# I /could/ have made it more complicated, but that would defeat the point!
import random
print "Enter a range of digits."
# Get those numbers...
minVal = input("\tYour minimum value: ")