Skip to content

Instantly share code, notes, and snippets.

View Darker's full-sized avatar

Jakub Mareda Darker

  • Czech Republic
View GitHub Profile
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>PyPy</title>
</head>
<body>
<h2>Select python file</h2>
<input type="file" id="files" name="file" multiple />
@Darker
Darker / KOS_multiple_tabs.user.js
Created February 3, 2017 18:46
Userscript to allow students of CTU to open multiple tabs of KOS
// ==UserScript==
// @name KOS multiple tabs
// @namespace util
// @description Allows you to use KOS in mutiple tabs.
// @include https://www.kos.cvut.cz/kos/*
// @version 1
// @grant none
// ==/UserScript==
// Name of local storage entry where page id is stored
const DATA_NAME = "KOS_PAGE_ID";
@Darker
Darker / HomeworkTestBase.java
Last active March 8, 2017 17:16
Example of JUnit test for CTU PJV homework assignment 01
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
void Image::convolute(const int matrix[3][3], Image& target)
{
target.setSize(getWidth(), getHeight());
for(size_t y=0, yl=getHeight(); y<yl; ++y) {
for(size_t x=0, xl=getWidth(); x<xl; ++x) {
if(x==0 || y==0 || x+1==xl || y+1==yl) {
target.pixels[y][x] = pixels[y][x];
}
else {
target.pixels[y][x] = ((pixels[y-1][x-1]*matrix[0][0])
@Darker
Darker / spam_phishing.py
Created June 23, 2017 12:40
Sends random usernames and password to a phishing script to fuck with it
import httplib, urllib
params = {
"app": "",
"login_post": "1",
"url": "",
"anchor_string": "",
"username": "dsavffsfds",
"password": "fdsfdsfdsfds",
"horde_select_view": "auto",
"new_lang": "en_US"}
console.log("This script changes cached resources' path in GreaseMonkey addon folder to force refresh.");
console.log("Press any key to start adding files.");
/*process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', ()=>{getFiles(updateLoop);}); */
var fs=require("fs");
var path = require("path");
/*var prompt = require('prompt-sync');
@Darker
Darker / casy.js
Created September 3, 2017 18:11
Lesson times at ctu
var casy2 = [
["7:30", "8:15"],
["8:15", "9:00"],
["9:15", "10:00"],
["10:00", "10:45"],
["11:00", "11:45"],
["11:45", "12:30"],
["12:45", "13:30"],
["13:30", "14:15"],
["14:30", "15:15"],
@Darker
Darker / gist:f081d5c9de04cdc31a93406f6b1e5c1a
Created September 4, 2017 20:59
Sablona pro analyzu otevrenych uctu ve fio bance.
var halire = 0;
var prispevky = 0;
document.querySelectorAll("td.amount.amount_value").forEach(function(elm) {
const cash = elm.getAttribute("data-value")*1;
if(cash>1) prispevky +=cash;
else halire+=cash;
});
[halire, prispevky]
@Darker
Darker / My answer.md
Created February 9, 2018 10:32
Answer

There's multiple issues:

  • somethingIsTrue ? doSomething(); is not valid in JavaScript. See MDN on ternary operator
  • Frankly, I don't think Array.prototype.reduce is the right choice. Reduce creates something from all array members. I mean you could use it for this, but the code would be unnecesarily obscure. For generic looping, use either map (1:1 conversion of array elements) or forEach

I'd use forEach, or just classic for:

# generated by Slic3r 1.3.0-dev on Fri Feb 23 16:52:42 2018
[filament:ColorFabb Brass Bronze 1.75mm]
bed_temperature = 50
bridge_fan_speed = 100
compatible_printers =
cooling = 1
disable_fan_first_layers = 1
end_filament_gcode = "; Filament-specific end gcode \n;END gcode for filament\n"
extrusion_multiplier = 1