Skip to content

Instantly share code, notes, and snippets.

View Pepijn98's full-sized avatar
👽
Writing out of this world code

Pepijn van den Broek Pepijn98

👽
Writing out of this world code
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kurozeropb on github.
  • I am kurozero (https://keybase.io/kurozero) on keybase.
  • I have a public key whose fingerprint is 113B 2D92 B201 90AC 56E6 8666 389C 3D40 9148 70CC

To claim this, I am signing this object:

@Pepijn98
Pepijn98 / save_to_yaml.py
Last active January 9, 2018 22:05
discord.py command to save modlogs to a yaml file. (Quick solution to a problem, better to use a database)
@commands.guild_only()
@commands.has_permissions(manage_guild=True)
@commands.command(name='modlog')
async def set_modlog(self, ctx, channel: discord.TextChannel):
"""Set the modlog channel"""
with open('db/guild_settings.yaml', 'r+') as yaml_file:
yaml_data = yaml.load(yaml_file)
keys = list(yaml_data.keys())
if f'{ctx.guild.id}' in keys:
if yaml_data[f'{ctx.guild.id}']['modlog'] == str(channel.id):
@Pepijn98
Pepijn98 / reformat-json.js
Created February 8, 2018 01:38
Re-format some "json"
const fs = require("fs");
const json = require("./points.json");
let array = [];
Object.keys(json).map((key, index) => {
let temp = {
"userID": key,
"level": json[key].level,
"points": json[key].points,
@Pepijn98
Pepijn98 / json2csv.js
Created February 8, 2018 01:45
Convert json to csv
const converter = require('json-2-csv');
const fs = require('fs');
const points = require('./points-new.json');
converter.json2csv(points, (err, data) => {
fs.writeFile(`${__dirname}/points.csv`, data, 'utf8', (err) => {
if (err) {
console.log(`Some error occured - file either not saved or corrupted file saved.\n${e}`);
} else{
@Pepijn98
Pepijn98 / extend-string-storage.js
Last active September 12, 2018 13:44
Extend String and Storage with some useful properties and methods in my opinion
/**
* Set multiple storage items
* @param {Object} items
*/
Storage.prototype.setItems = function (items) {
for (let item in items) {
if (items.hasOwnProperty(item)) {
let itemToSet = "";
if (typeof items[item] === 'object')
itemToSet = JSON.stringify(items[item]);
/**
* @author KurozeroPB
*/
class Numbers {
/**
* Create a new instance
* @param {Number|Number[]} seed
*/
constructor(seed) {
if (seed == undefined) {
func countries(in grid: inout [[Int]]) -> Int {
let height = grid.count
let width = grid[0].count
var flag = 0
var flagCount = 0
func cascade(x: Int, y: Int) {
guard grid[y][x] == flag else {
return
data class Time(var hours: Int, var mins: Int) {
operator fun plus(time: Time): Time {
val minutes = this.mins + time.mins
val hoursInMinutes = minutes / 60
val remainingMinutes = minutes % 60
val hours = this.hours + time.hours + hoursInMinutes
return Time(hours, remainingMinutes)
}
operator fun minus(time: Time): Time {
Kotlin 7 hrs 43 mins ██████████████▎░░░░░░ 68.0%
XML 2 hrs 52 mins █████▎░░░░░░░░░░░░░░░ 25.2%
TypeScript 16 mins ▌░░░░░░░░░░░░░░░░░░░░ 2.4%
JavaScript 13 mins ▍░░░░░░░░░░░░░░░░░░░░ 2.0%
Markdown 12 mins ▍░░░░░░░░░░░░░░░░░░░░ 1.9%
@Pepijn98
Pepijn98 / twitch.js
Last active August 27, 2020 23:15
Simple nodejs script to quickly pull channel info from the twitch api (no npm packages required)
#! /usr/bin/env node
const https = require("https");
const fs = require("fs");
const fsp = require("fs/promises");
const path = require("path");
const help_options = ["help", "--help", "-h"];
const config_dir = path.join(process.env.HOME, ".config", "twitch");