Skip to content

Instantly share code, notes, and snippets.

View longstone's full-sized avatar

longstone

  • Zürich, Switzerland
  • 07:33 (UTC +02:00)
View GitHub Profile
@longstone
longstone / CaesarImplTest.java
Created May 5, 2020 12:47
Testfile for simple caesar implementation
package ch.bwz.m183.caesar;
import static org.junit.jupiter.api.Assertions.*;
class CaesarImplTest {
@org.junit.jupiter.api.Test
void encrypt_smokeTest_Valid() {
String encrypted = new CaesarImpl().encrypt("abc", 23);
assertEquals("xyz", encrypted);
<?php
$val = htmlspecialchars($_REQUEST['cookieval']);
$key = htmlspecialchars($_REQUEST['cookiekey']);
if(isset($val) && $val != "" && isset($key)) {
// todo create http only cookies
setcookie($key, $val);
echo "cookie $key = $val set";
}
?>
@longstone
longstone / gist:c4ce05a8e4a4acdabcd94b111f2b930c
Created August 14, 2018 17:48
remove 20minutes.ch paywall by jquery script
$(document).load(function () {
// remove paywall
$("div[style='display: block;']").remove();
// enable scrollbar
$('body').css('overflow-y','auto');
});
@longstone
longstone / Jira set resolution to Done
Last active October 11, 2017 11:29
Shows how to set resolutions to done when no access to admin functionality...
/**
* you need to be able to change resolutions...
* use a this page: https://jira.url/browse/ticketRef?jql=project%20%3D%20%27PROJECTNAME%27%20and%20resolution%20%3D%20Unresolved%20and%20status%20%3D%20done
* for all resolution check:
* <select name="resolution" class="select" id="resolution">
* <option selected="selected" value="1">
* ...
*
**/
var arr= $('.issue-list li a');
@longstone
longstone / request with filter
Created October 3, 2015 08:31
a request with filter , count and trainingset
{
"count": 1,
"filterInclude": {
"brand": "SKODA",
"psMin": 100,
"priceMax": 30000
},
"trainingSet": [
{
"input": {
@longstone
longstone / sample response
Created October 3, 2015 05:02
with computed probability of a match
{
"data": [
{
"brand": "SKODA",
"model_de": "SUPERB LIMOUSINE STYLE",
"engine_de": "2000ccm 190PS/140kW 4 Zylinder TDI SCR Diesel",
"fuel_type": "D",
"engine_capacity": 2000,
"power_hp": 190,
"sale_type": "Demo",
@longstone
longstone / sample request
Created October 3, 2015 05:00
start at 5, get 1 element, and send some training input
{
"offset": 5,
"count": 1,
"trainingSet": [
{
"input": {
"price": 10000
},
"output": {
"match": 1
@longstone
longstone / Promise-Node-0.12.js
Created June 23, 2015 02:04
short example for native promise in node 0.12
/**
* Created by longstone on 23/06/15.
*/
var promisemagic = function (millisecondsToWait, success) {
var promise = new Promise(function (resolve, reject) {
setTimeout(function () {
if (success) {
resolve('yay');
} else {