Skip to content

Instantly share code, notes, and snippets.

@Norod
Norod / otfHorizontalTableModify.m
Last active August 29, 2015 13:57
Demonstrate how to load an OTF file, change some if its internal values in-memory (Ascender, Descender, LineGap), register it and then create a UIFont object
#import <CoreText/CoreText.h>
#define kOTFhorizontalHeaderTableRecord_tag htonl((int32_t)('hhea'))
typedef struct otfTableRecordStruct
{
int32_t tag;
int32_t checksum;
int32_t offset;
int32_t length;
@Norod
Norod / BenchmarkArray_firstObject_lastObject.m
Created July 11, 2014 18:47
Benchmark average time of [array firstObject] calls and [array lastObject] calls. Result - Sim: No difference, iPad 2: 0.9% - 2.1% in favour of firstObject
//
// ViewController.m
// testDispatchBenchmark
//
// Created by Doron Adler on 7/11/14.
//
#import "ViewController.h"
#include <mach/mach.h>
#include <mach/mach_time.h>
@Norod
Norod / tensorflow_r1.8_rc1_macOS_myBuildSettings.txt
Last active May 21, 2018 10:38
tensorflow_r1.8_rc1_macOS_patch.diff
exports
-------
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=/Users/dadler/lib:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH
bazel
-----
I used bazel 0.10.0 (installed from bazel-0.10.0-installer-darwin-x86_64.sh)
@Norod
Norod / immintrin.h
Created March 26, 2019 08:51
Workaround for "GNU-style inline assembly is disabled" error in Xcode 10.2 simulator for WatchOS 5.2 (See line 347)
/*===---- immintrin.h - Intel intrinsics -----------------------------------===
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
@Norod
Norod / fbytlink_semi_auto_extract.sh
Last active June 23, 2019 08:43
How to extract a list of Youtube links from a Facebook discussion thread and generate a playlist
@Norod
Norod / subxml2txt.py
Last active July 16, 2020 15:46
Read xml in OpenSubtitles format, output text intended for training machine learning models
#Read xml in OpenSubtitles format, output text intended for training machine learning models
import sys
from os import path
import time
import xml.etree.ElementTree as ET
if len(sys.argv) != 2:
print("Usage: "+ str(sys.argv[0]) + " input.xml")
exit(-1)
@Norod
Norod / openssl-build.sh
Last active July 19, 2020 22:33 — forked from foozmeat/openssl-build.sh
A shell script to build openssl for iOS and Mac. >>>>> It currently builds: Mac (i386, x86_64) >>>>> iOS (armv7, arm64) >>>>> iOS Simulator (i386, x86_64) >>>>> Updated to work with Xcode 7 and produce bitcode enabled binaries >>>>> Minimum deployment target can be easily configured
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries with Bitcode enabled
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Doron Adler, GlideTalk, @Norod78
@Norod
Norod / hewiki-articles-distilgpt2py-il.ipynb
Created July 22, 2020 14:02
hewiki-articles-distilGPT2py-il.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / stage.py
Last active August 2, 2020 16:01
Parse index.html files from the website stage.co.il
#Grab archived stories from stage.co.il using
#wayback_machine_downloader -c 8 -a http://stage.co.il/Stories
#
#This script, reads a "stage.co.il" index.html file and outputs the following HTML tag dirty text:
#Author name
#Title
#Story
#<|endoftext|>
@Norod
Norod / CoreML_distilGPT2.py
Created May 6, 2021 14:25
Various Huggingface GPT2 to CoreML converters. To be used with https://github.com/huggingface/swift-coreml-transformers.git
"""
Recreate the Core ML model from scratch using
coremltools' neural_network.NeuralNetworkBuilder
"""
import coremltools
import coremltools.models.datatypes as datatypes
from coremltools.models import neural_network as neural_network
from coremltools.models.utils import save_spec
import numpy as np