Skip to content

Instantly share code, notes, and snippets.

@pasmat
pasmat / changeUrlParameters.php
Created November 30, 2019 10:53
An function to modify parameters within url, either to change them or replace them. Useful when doing dynamic redirects based on current url.
<?php
static function changeParameters($url, $parameters)
{
$urlParts = parse_url($url);
$url = "";
if (isset($urlParts['scheme'])) {
$url .= $urlParts['scheme'] . "://";
@pasmat
pasmat / DateIntervalToSQL.php
Created January 23, 2019 10:43
turn php DateInterval object to SQL date interval calculation by generating SQL code that adds or subtracts given dateinterval from a variable
/**
* turn php DateInterval object to SQL date interval calculation
* by generating SQL code that adds or subtracts given dateinterval
* from a variable
*
* @param DateInterval $interval the interval to subtract or add
* @param $sqlVariable the variable on which the calculation should be performed on, probably now() or some column
* @param string $sqlFunction the function to use to calculate the date, probably either DATE_SUB or DATE_ADD
* @return string sql time calculation
*/
@pasmat
pasmat / Boxer.java
Created August 22, 2018 14:25
Data-binded values that are boxed(such as ones that come from Kotlin, as there's no primitive types in Kotlin..) requires safe unboxing, so there's no NPE(null pointer exception) when binding data. Theres a method for this safeUnbox inside Android SDK, however this doesn't support two-way data binding. Therefore we have to define these two-way s…
package fi.matalamaki.util;
import androidx.databinding.InverseMethod;
/**
* Data-binded values that are boxed(such as ones that come from Kotlin,
* as there's no primitive types in Kotlin..) requires safe unboxing,
* so there's no NPE(null pointer exception) when binding data.
*
* Theres a method for this safeUnbox inside Android SDK,
@pasmat
pasmat / mineways-fix.py
Created June 5, 2018 17:58
Fix MineWays white textures/alpha for blender
'''
This script goes through every textureSlot setting settings such that the blocks are rendered correctly in the scene
beware, this sets those properties for ALL objects, so this script should when theres only the world on the scene
also, I've only programmed in python for blender scripting, so the code may be substandard for other pythonists out there
'''
import bpy
objects = bpy.data.objects