Skip to content

Instantly share code, notes, and snippets.

View pczajkowski's full-sized avatar
🙉
I have no idea what I'm doing

Piotr Czajkowski pczajkowski

🙉
I have no idea what I'm doing
View GitHub Profile
#get time
MYTIME=$(date)
#get IPs
IP=$(/sbin/ip -o -4 addr list | awk '{print $2 ": ", $4}')
#remove linebreak
IPF=$(echo $IP)
#json content
post='{"public":false,"files":{"IP.txt":{"content":"'$MYTIME' : '${IPF}'"}}}'
#create a command
crl="curl --header 'Authorization: bearer YOUR_TOKEN_HERE' --header 'Accept: application/json' --header 'Content-type: application/json' --request POST --data '${post}' https://api.github.com/gists"
@pczajkowski
pczajkowski / bubble.c
Created December 27, 2017 12:54
Sorting algorithms in C
void bubbleSort(int list[], int listLength) {
int doItAgain = 0;
for (int i = 0; i < listLength; i++) {
int thisValue = list[i];
int nextValue = (i + 1 < listLength) ? list[i+1] : INT_MAX;
if (nextValue < thisValue) {
list[i] = nextValue;
list[i+1] = thisValue;
public static class ReportFactory
{
public static IReport<T> CreateReport<T>()
{
if (typeof(T) == typeof(OrdersInfoBiWeekly))
return (IReport<T>) new OrdersInfoBiWeekly();
if (typeof(T) == typeof(ContentTypeInfo))
return (IReport<T>) new ContentTypeInfo();
private static async Task<List<string>> DownloadTMXsAsync(List<TMInfo> tms)
{
List<Task> tasks = new List<Task>();
List<string> tmxs = new List<string>();
foreach (var tm in tms)
{
tasks.Add(Task.Run(async () =>
{
var result = await _memoQTM.DownloadTMXAsync(".", tm.Guid);
if (result.status.Equals("ok", StringComparison.InvariantCultureIgnoreCase))
public string AppName
{
get
{
if (!string.IsNullOrEmpty(_appName))
return _appName;
var name = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
if (string.IsNullOrEmpty(name))
throw new Exception("Can't establish app name!");
@pczajkowski
pczajkowski / mergePDFs.cs
Last active September 25, 2019 13:30
PoC to demonstrate how easy it is to merge PDFs. Based on https://stackoverflow.com/a/808699/7342859
using System;
using System.IO;
using System.Linq;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace MergePDFs
{
internal class Program
{

Keybase proof

I hereby claim:

  • I am pczajkowski on github.
  • I am pczajkowski (https://keybase.io/pczajkowski) on keybase.
  • I have a public key whose fingerprint is 661E A005 5FE5 39D5 5B06 2876 9AF4 CFB6 E475 1A47

To claim this, I am signing this object:

@pczajkowski
pczajkowski / printTextForGivenElement.js
Created April 10, 2020 11:19
printTextForGivenElement.js
const fs = require('fs');
const cheerio = require('cheerio');
const puppeteer = require('puppeteer');
let app = {};
app.parse = async function(data, elementSelector) {
if (data.length === 0) {
console.log("No data!");
return;
}
@pczajkowski
pczajkowski / epidemic.js
Created May 10, 2020 14:55
Coding dojo golf
const WIDTH = 8;
const HEIGHT = 8;
// https://www.coding-dojo-silesia.pl/golf
function point_free(x, y, people) {
const pLength = people.length;
for (let i = 0; i < pLength; i++) {
const person = people[i];
if (x === person.x && y === person.y)
@pczajkowski
pczajkowski / translations.txt
Created October 8, 2020 16:52
translations.txt
constant "someID", "sourceText"
translation
constant "someOtherID", "otherSourceText
which is multiline"
another translation