Skip to content

Instantly share code, notes, and snippets.

View jazerix's full-sized avatar
🪄
Conjuring Code

Niels Faurskov jazerix

🪄
Conjuring Code
View GitHub Profile
<?php
/**
* @param $query The string you wish to search for
* @param array database columns to include in search
* @return string SQL where clause
*/
public function createWhereClause($query, array $fields)
{
$words = explode(' ', $query);
foreach ($fields as $field)
@jazerix
jazerix / elements.json
Last active April 29, 2018 22:10
List of elements from the periodic table.
[
{
"Number": 1,
"Type": "Nonmetal",
"Mass": 1.008,
"Name": "Hydrogen",
"Acronym": "H",
"Electrons": [
1
],
@jazerix
jazerix / counter.ps1
Last active May 27, 2023 12:02
Latex Character count with spaces. Depends on the texcount library for Latex.
function countLatex{
param([string] $file)
$c = texcount .\$file.tex -char | select-string "Letters in text";
$c = [int]$c.Line.substring(17);
$w = texcount .\$file.tex | select-string "Words in text";
$w = [int]$w.Line.substring(15)
$total = $c + $w;
return $total;
}
@jazerix
jazerix / TileGroups.cs
Created October 26, 2019 21:50
Calculate Zoomify TileGroups with Vips
public static int MaxTileGroup(Layer layer)
{
int x = layer.tiles_across-1;
int y = layer.tiles_down-1;
int n = 0;
Layer below = layer.below;
while(below != null)
{
n += below.tiles_across * below.tiles_down;
@jazerix
jazerix / gitlab-downloader.js
Created March 9, 2023 10:34
GitLab Group Downloader - Downloads all projects from a given group in GitLab. Takes two arguments: id of the group and then a folder name to save the projects to
var fs = require('fs');
var path = require('path');
const https = require('https');
const cliProgress = require('cli-progress');
const decompress = require("decompress");
async function download()
{
if (!fs.existsSync(path.join(__dirname, "downloads")))
fs.mkdirSync(path.join(__dirname, "downloads"));
@jazerix
jazerix / migrate.py
Created March 12, 2024 11:10
This is a migration script for migrating your testrail attachments to cassandra.
import subprocess
import time
import mysql.connector
from mysql.connector import Error
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
contact_points = ['localhost']
username = 'testrail'
password = 'secret'