Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Allan Amstadt iteufel

🚀
View GitHub Profile
View keys.pub
BEGIN MESSAGE.
6ofxjYA8SxDQd25 PKMBkRXQAQeOSob aY6ZrZ3w1GZU5G2 SvDsbBeWrKa5K1E
0d6evZNc2w6v8JZ jIilUsLWbvLTCKq 6Xr2MZHgg6ZyC1B m9NNWWZvwf01K5t
u1WEcwlp0S4qY2H 98FGIve520xpiEx g2GZYe9420ZMYHF gobVWv0BUQmtPt7
xZzYUDJp5yjBAiX Nk1CxLhnL6LvsRB i8si22IP.
END MESSAGE.
@iteufel
iteufel / nestedDelete.ts
Last active Jul 24, 2019
TypeOrm delete Nested
View nestedDelete.ts
import { getManager } from 'typeorm';
import * as dotProp from 'dot-prop';
export async function deleteNested (item: any) {
const meta = getRemoveRelations(item.constructor, '');
const res = await getManager().findOneOrFail(item.constructor, item, {
relations: meta
})
await getManager().remove(res);
for (const path of meta) {
@iteufel
iteufel / typeormDataListeners.ts
Created Jul 23, 2019
Register Typeorm Data Listeners without using decorators
View typeormDataListeners.ts
import { EventListenerType } from 'typeorm/metadata/types/EventListenerTypes';
import { getManager, EntitySchema } from 'typeorm';
import { EntityListenerMetadata } from 'typeorm/metadata/EntityListenerMetadata';
export function addDatabaseListener (entity: EntitySchema<any> | Function | string, type: EventListenerType, handler: Function) {
const meta = getManager().connection.getMetadata(entity);
let r = '_' + Math.random().toString(36).substring(7);
(meta.target as any).prototype[r] = handler;
const el = new EntityListenerMetadata({
entityMetadata: meta,
@iteufel
iteufel / zipcodes.germany.sql
Created Sep 19, 2017
German Zip codes with coordinates and names
View zipcodes.germany.sql
This file has been truncated, but you can view the full file.
# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.7.16-0ubuntu0.16.04.1)
# Generation Time: 2016-12-21 12:35:15 +0000
View Arguments to NSDictionary
- (NSDictionary*)argsToDictionary{
//Get the arguments as an Array
NSMutableArray *arguments = [[NSMutableArray alloc]initWithArray:[[NSProcessInfo processInfo] arguments]];
//remove the path
[arguments removeObjectAtIndex:0];
//create the temp mutabledict
NSMutableDictionary *argsdict = [NSMutableDictionary dictionary];
for (int i=0; i<arguments.count; i++) {
if (arguments.count > i+1){
@iteufel
iteufel / mimetypes.plist
Created Jun 19, 2014
A Plist with all Mimetypes from the Apache httpd project.
View mimetypes.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>123</key>
<string>application/vnd.lotus-1-2-3</string>
<key>3dml</key>
<string>text/vnd.in3d.3dml</string>
<key>3ds</key>
<string>image/x-3ds</string>
@iteufel
iteufel / WebViewWithCustomJsContext.mm
Created Jun 10, 2014
How to extend a WebView with a Custom JSContext
View WebViewWithCustomJsContext.mm
//how to extend a webview with custom Javascript functions
.....
#import <JavaScriptCore/JavaScriptCore.h>
#import <JavaScriptCore/JSBase.h>
.....
_webview.mainFrame.javaScriptContext[@"download"] = ^(NSString *url) {
//do something
};