Skip to content

Instantly share code, notes, and snippets.

View gregoryvit's full-sized avatar

Gregory Berngardt gregoryvit

View GitHub Profile
@mbinna
mbinna / podforceupdate.sh
Created December 4, 2012 09:43
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@alanhamlett
alanhamlett / api.py
Last active June 28, 2024 08:15
Serialize SQLAlchemy Model to dictionary (for JSON output) and update Model from dictionary attributes.
import uuid
import wtforms_json
from sqlalchemy import not_
from sqlalchemy.dialects.postgresql import UUID
from wtforms import Form
from wtforms.fields import FormField, FieldList
from wtforms.validators import Length
from flask import current_app as app
from flask import request, json, jsonify, abort
@iezg
iezg / gist:7184686
Created October 27, 2013 16:37
Python in OSX Mavericks
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
@jianpx
jianpx / wwdc2014-videos-and-pdf
Created June 7, 2014 13:42
wwdc 2014 videos and pdf download links, including HD/SD version.
http://devstreaming.apple.com/videos/wwdc/2014/403xxksrj0qs8c0/403/403_hd_intermediate_swift.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/403xxksrj0qs8c0/403/403_sd_intermediate_swift.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/403xxksrj0qs8c0/403/403_intermediate_swift.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/419xxli6f60a6bs/419/419_hd_advanced_graphics_and_animation_performance.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/419xxli6f60a6bs/419/419_sd_advanced_graphics_and_animation_performance.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/419xxli6f60a6bs/419/419_advanced_graphics_and_animation_performance.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/101xx36lr6smzjo/101/101_hd.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/101xx36lr6smzjo/101/101_sd.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/236xxwk3fv82sx2/236/236_hd_building_interruptible_and_responsive_interactions.mov?dl=1
http://devstreaming.apple.com/videos/wwdc/2
@twolfson
twolfson / README.md
Created February 23, 2015 22:45
Python unittest `setUp` inheritance

In some cases for Python unit tests, we want to automatically perform setUp methods in as declared in a base class. However, we still want setUp to work as per normal in the subclass. The following code will proxy the new setUp function to run it's base class' and the new one.

# Define a common test base for starting servers
class MyBaseTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        """On inherited classes, run our `setUp` method"""
        # Inspired via http://stackoverflow.com/questions/1323455/python-unit-test-with-base-and-sub-class/17696807#17696807
        if cls is not MyBaseTestCase and cls.setUp is not MyBaseTestCase.setUp:
@naturaln0va
naturaln0va / LocationVCard.swift
Created February 4, 2016 19:32
Create a location vCard for use in UIActivityViewController like in Apple's Maps app.
import CoreLocation
func locationVCardURLFromCoordinate(coordinate: CLLocationCoordinate2D) -> NSURL?
{
guard let cachesPathString = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).first else {
print("Error: couldn't find the caches directory.")
return nil
}
@nevan
nevan / wwdc_2016_videos.txt
Last active February 23, 2024 06:53
WWDC 2016 Video Titles and URLs
101 Keynote http://devstreaming.apple.com/videos/wwdc/2016/101g0jrsvv5qcoduisk/101/101_hd_keynote.mp4
102 Platforms State of the Union http://devstreaming.apple.com/videos/wwdc/2016/102w0bsn0ge83qfv7za/102/102_hd_platforms_state_of_the_union.mp4
103 Apple Design Awards http://devstreaming.apple.com/videos/wwdc/2016/103m0752oxdkymyk6gy/103/103_hd_apple_design_awards.mp4
201 Internationalization Best Practices http://devstreaming.apple.com/videos/wwdc/2016/201h1g4asm31ti2l9n1/201/201_hd_internationalization_best_practices.mp4
202 What's New in Accessibility http://devstreaming.apple.com/videos/wwdc/2016/202w2zhc4l8yomptqnt/202/202_hd_whats_new_in_accessibility.mp4
203 What's New in Cocoa http://devstreaming.apple.com/videos/wwdc/2016/203x2w42att1kdzg1ce/203/203_hd_whats_new_in_cocoa.mp4
204 iMessage Apps and Stickers Part 1 http://devstreaming.apple.com/videos/wwdc/2016/204t23fvanrkj7a1oj7/204/204_hd_imessage_apps_and_stickers_part_1.mp4
205 What's New in Cocoa Touch http://devstreaming.apple.co
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active July 12, 2024 03:33
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@IsaacXen
IsaacXen / README.md
Last active July 23, 2024 08:00
(Almost) Every WWDC videos download links for aria2c.
@Miha-x64
Miha-x64 / Xml.java
Last active December 22, 2022 14:03
HTML/XML escaping utils, answering https://stackoverflow.com/a/61215915/3050249
import java.io.IOException;
import java.io.UncheckedIOException;
/**
* XML escaping utils.
*
* Source: https://gist.github.com/Miha-x64/4ed50f1d5593e45a452efbf456aa1db4
*/
public final class Xml {