Skip to content

Instantly share code, notes, and snippets.

View agermanidis's full-sized avatar
💭
🎭

Anastasis Germanidis agermanidis

💭
🎭
View GitHub Profile
@agermanidis
agermanidis / spec.md
Last active May 10, 2018 23:02
Bingo spec

Cyranoid Spec

A Script consists of instruction code, a set of roles, and related metadata (name, author, etc.).

Script
  code: executable code
  roles: [Role]
  metadata: dictionary
@agermanidis
agermanidis / DrawSizeGizmo.cs
Last active March 6, 2023 10:30
Draw Size Gizmo - Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[ExecuteInEditMode]
public class DrawSizeGizmo : MonoBehaviour {
public bool enabled = true;
void OnDrawGizmos () {
@agermanidis
agermanidis / microsoft_image_search.swift
Created November 21, 2017 19:58
Microsoft Image Search Request example - Swift
func microsoftImageSearch(_ query : String, completion: @escaping (_ result: [String])->()) {
let url = URL(string: "https://api.cognitive.microsoft.com/bing/v7.0/images/search?q=\(query)")
var request = URLRequest(url: url!)
request.addValue(MICROSOFT_API_KEY, forHTTPHeaderField: "Ocp-Apim-Subscription-Key")
URLSession.shared.dataTask(with:request, completionHandler: {(data, response, error) in
guard let data = data, error == nil else { return }
do {
@agermanidis
agermanidis / ner.swift
Created November 21, 2017 16:58
Named Entity Extraction - Swift
func getEntities (_ sentence : String) -> [String] {
let tagger = NSLinguisticTagger(tagSchemes: [.nameType], options: 0)
let options: NSLinguisticTagger.Options = [.omitPunctuation, .omitWhitespace]
tagger.string = sentence
let range = NSRange(location:0, length: sentence.utf16.count)
var prevTag : NSLinguisticTag? = nil
var accName : String = ""
@agermanidis
agermanidis / classification_helpers.py
Last active July 5, 2021 05:19
pytorch classification model helpers
import time
import torch
def validate(val_loader, model, criterion, use_cuda=False, print_freq=10):
"""
Evaluate a classification model on the entire validation set.
Args:
val_loader: a DataLoader instance for the validation set
model: the model to evaluate
@agermanidis
agermanidis / scrape_ad_preferences.py
Created March 19, 2017 10:25
Scrape your Ad Preferences on FB
import sys
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-notifications")
driver = webdriver.Chrome(chrome_options=chrome_options)
@agermanidis
agermanidis / resize_many.sh
Last active May 30, 2021 21:57
bash script to resize an image to multiple sizes with one command using ImageMagick
#!/bin/bash
# Usage: ./resize_many.sh <filename> <sizes...>
# e.g. ./resize_many.sh myasset.png 10x10 20x20 30x30
# produces 3 files, myasset10x10.png myasset20x20.png myasset30x30.png
fullname=$1
shift;
sizes=$*
extension="${fullname##*.}"
import sys
import numpy as np
import colorlover as cl
import scipy.io.wavfile as wav
from scipy.interpolate import interp1d
from python_speech_features import fbank
from PIL import Image
N_FILTERS = 10
N_FRAMES = 60

Keybase proof

I hereby claim:

  • I am agermanidis on github.
  • I am anastasis (https://keybase.io/anastasis) on keybase.
  • I have a public key ASD-UX-y5q5BzGrbbfhOUHDEGdGP-47udjWt3qUHtCpk4Qo

To claim this, I am signing this object:

@agermanidis
agermanidis / poems.jsonl
Created April 20, 2016 11:09
1000 poems from Poetry Foundation in jsonl fomrat
This file has been truncated, but you can view the full file.
{"poem": "If the hope of giving\n\r is to love the living,\n\r the giver risks madness\n\r in the act of giving.\n\n\r Some such lesson I seemed to see\n\r in the faces that surrounded me.\n\n\r Needy and blind, unhopeful, unlifted,\n\r what gift would give them the gift to be gifted?\n\r \u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0The giver is no less adrift\n\r \u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0than those who are clamouring for the gift.\n\n\r If they cannot claim it, if it is not there,\n\r if their empty fingers beat the empty air\n\r and the giver goes down on his knees in prayer\n\r knows that all of his giving has been for naught\n\r and that nothing was ever what he thought\n\r and turns in his guilty bed to stare\n\r at the starving multitudes standing there\n\r and rises from bed to curse at heaven,\n\r he must yet understand that to whom much is given\n\r much will be taken, and justly so:\nI cannot tell how much I owe.\n", "title": "The giver (for Berdis)", "id": 88930, "author": "James Baldwin"