Skip to content

Instantly share code, notes, and snippets.

View 19h's full-sized avatar
✔️
This account is verified.

Kenan Sulayman 19h

✔️
This account is verified.
View GitHub Profile
@19h
19h / code.ts
Created March 28, 2024 01:47
Github Copilot goes bonkers
const x = (full_name): string[] => {
citizen_database.filter(person =>
/ibrahim|ali|mohamm(?:a|e)d/.test(person.name),
).forEach(person =>
(person.tags.push('illegal immigrant'), person)
);
const x = () => {
citizen_database.filter(person =>
/ibrahim|ali|mohamm(?:a|e)d/.test(person.name),
@19h
19h / embedder.py
Created November 3, 2023 23:18
This Python code efficiently extracts sentence embeddings from a CSV of news articles using a pretrained BERT model. It batches titles, generates embeddings, serializes them, and writes the embeddings and metadata to a new CSV file.
import csv
import json
import torch
from tqdm import tqdm
from transformers import AutoModel, BertTokenizerFast
import ctypes as ct
csv.field_size_limit(int(ct.c_ulong(-1).value // 2))
model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en', trust_remote_code=True)
@19h
19h / embedder.py
Created November 3, 2023 23:16
This Python code efficiently extracts sentence embeddings from a large CSV dataset of news articles using a pretrained BERT model for natural language processing. It first loads the BERT model and tokenizer, then reads the input CSV row by row, extracting the title and article text. It batches the titles, feeds them to the BERT model to generate…
import csv
import json
import torch
from tqdm import tqdm
from transformers import AutoModel, BertTokenizerFast
import ctypes as ct
csv.field_size_limit(int(ct.c_ulong(-1).value // 2))
model = AutoModel.from_pretrained('jinaai/jina-embeddings-v2-base-en', trust_remote_code=True)
@19h
19h / parseMp4.js
Last active June 25, 2023 02:06
MP4 tkhd parser, works no matter how fucked your mp4 buffer is as long as it contains a tkhd box -- will give you dimensions (width, height), duration, creation time, modification time, track id, layer, alternate group, volume, the entire matrix, flags and version of the mp4 file.
const readU8 = (data, offset) =>
data[offset];
const readU16 = (data, offset) =>
(
data[offset] << 8
| data[offset + 1]
);
const readU24 = (data, offset) =>
@19h
19h / insta-dumper.js
Last active September 4, 2022 02:59
Instagram following followers network graph dumper crawler spider node.js api / private api
const { IgApiClient, IgLoginTwoFactorRequiredError } = require('instagram-private-api');
const inquirer = require('inquirer');
const Bluebird = require('bluebird');
const fs = require('fs');
process.env.IG_USERNAME = 'xxx';
process.env.IG_PASSWORD = 'xxx';
const ig = new IgApiClient();
@19h
19h / pbzx2.c
Created June 26, 2020 00:32
pbzx2.c
###### WARNING: PRIOR WORK: https://gist.githubusercontent.com/xerub/adf396f479d401b9c0e9/raw/18db6c9211a57f969a3c6063554a3ff82c44e1fa/pbzx2.c
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <lzma.h>
int main(int argc,
@19h
19h / preconnecter.ts
Last active December 30, 2018 04:17
preconnect hooker for external links
// https://gist.github.com/KenanSulayman/2da1085913b94add85315e08959bafa6
;(() => {
const runner = () => {
const processed: string[] = [];
const preconn = (type: string, url: string) => {
if (~processed.indexOf(url)) {
return;
}
@19h
19h / app.ts
Created December 14, 2018 00:42
PsychonautWiki Global Drug Survey Banner (SubstanceBox)
declare interface Window {
wgPageName?: string;
wgCategories?: string;
}
class Pr1ce {
protected _container?: HTMLTableSectionElement;
protected _pageName?: string;
protected _categories?: string;
protected _facts: string[];
@19h
19h / jenkins-material-theme.css
Created November 21, 2018 13:54
jenkins-css
undefined#header{background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAACg4AAAL4CAYAAACps554AAAKzmlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUU9kWQO97L73QAhGQEnoTpAgEkBJCCyAgHWyEJJBQYkgIKjZUBkdwLKiIoDKioyIKNorYEAu2QbGAfYIMIuo4WLCh5j/gE2b+X///9c9aZ939zjv3nHPfuvetcwGgErgSSRasAUC2OFcaHezPSExKZuCfAhzAAjKwB3guTyZhRUWFA1TGx7/Lhy4AjYy37Udi/fv7/yqafIGMBwAUhXIqX8bLRvk4qoM8iTQXAGQPajdbkCsZ4csoa0vRAlF+NMLpYzw4wqmjjMGM+sRGs1HWBYBA4XKl6QBQzFE7I4+XjsahBKDsKOaLxCijz8CHJ+TyUUbzginZ2fNHWIGydepf4qT/LWaqKiaXm67isbWMCiFAJJNkcRf9n5/jf0t2lnw8hyWqFKE0JBod0bqge5nzw1QsTo2IHGcRf9R/lIXykLhx5snYyePM5waEqeZmRYSPc5ooiKOKk8uJHWeBLDBmnKXzo1W50qRs1jhzpRN55ZlxKrtQwFHFzxfGJoxznig+YpxlmTFhEz5slV0qj1bVLxAH+0/kDVKtPVv2l/WKOKq5ucLYENXauRP1C8SsiZiyRFVtfEFA4IRPnMpfkuuvyiXJilL5C7KCVXZZXoxqbi66ISfmRqm+YQY3NGqcQTgIBgwQB7JALpACLggCIiAGglzBwpE9CtjzJYukonRhLoOFnjIBgyPmOUxhODs6MQEYObNjW+IdffQsQvSrE7ZVNQB4n1AqlScnbKE3ATiSAgCpYcJmPQcAjX4ALp/iyaV5Y7aR44T+CUhAHWgDPWAEzIA1+ldwBm7AC/iBQBAKIkEsSAJzAQ8IQTZa+QKwBKwARaAEbABbQAWoArvBfnAIHAVN4BQ4By6Ba+AmuAseAgXoAy/BIP
@19h
19h / openssh.randomart.js
Created October 1, 2018 12:45
OpenSSH randomart
const defaultSymbols = 'ES .o+=*BOX@%&#/^'.split('');
const defaultBounds = {
width: 17,
height: 9
};
const generateBoard = (data, bounds) => {
/* create board */
const board = [];