Skip to content

Instantly share code, notes, and snippets.

View samuelbeek's full-sized avatar

Samuel Beek samuelbeek

View GitHub Profile
@samuelbeek
samuelbeek / Add and remove iCal events with your iOS app
Last active September 22, 2016 13:00
Add and remove iCal events with your iOS app.md
In order for this to work, you need to import Evenkit at the top of your file.
Then you can add the function setiCalEvent to your file and then you can simply use <code> [self setiCalEvent:true]; </code> or <code> [self setiCalEvent:false]; </code>. You don't need yo save any data inside your app to remove them later on, because the app does a search query.
@samuelbeek
samuelbeek / Full Screen Bootstrap Section Animation
Last active August 29, 2015 13:58
Full Screen Bootstrap Section Animation
Animating a section to full screen in with jquery:
A few notes:
- This was made in 5 minutes; it can be a little sloppy.
- You need to import JQuery in your page.
- It'll probably work with non bootstrap sites too, I haven't had time to test it.
- You need to bind the goFullScreen() function to some kind of action.
- This Gist is far from finished. Things I hope to add in the future include:
- Leave full screen
- Instead of moving the navbar, or some other element up. Diynamically select everything prior to the current sectino
$("form :input").each(function(index, elem) {
var eId = $(elem).attr("id");
var label = null;
if (eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1) {
$(elem).attr("placeholder", $(label).html());
$(label).remove();
}
});
@samuelbeek
samuelbeek / gist:3e6c632f27e069cc4a5e
Last active August 29, 2015 14:06
Remove big files from a git repo (your current one or one in the history). Very simple terminal command.
git filter-branch --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch MY-BIG-DIRECTORY-OR-FILE' --tag-name-filter cat -- --all
@samuelbeek
samuelbeek / showFonts.swift
Created October 31, 2014 15:49
Show all available fonts on iOS in Swift
for family in UIFont.familyNames() {
println(family);
var family: String = family as String
for name in UIFont.fontNamesForFamilyName(family) {
println(" \(name)");
}
@samuelbeek
samuelbeek / addContact.swift
Created December 14, 2014 05:01
Add contact to address book in swift
func addUserToAddressBook(contact: User){
let stat = ABAddressBookGetAuthorizationStatus()
switch stat {
case .Denied, .Restricted:
println("no access to addressbook")
case .Authorized, .NotDetermined:
var err : Unmanaged<CFError>? = nil
var adbk : ABAddressBook? = ABAddressBookCreateWithOptions(nil, &err).takeRetainedValue()
if adbk == nil {
println(err)
@samuelbeek
samuelbeek / convertToSeconds.js
Created February 2, 2015 15:56
Convert to time in seconds (javascript)
var convertToSeconds = function(time) {
if(!isNaN(time)){
return time
}
var timeArray = time.split(':'),
seconds = 0, minutes = 1;
while (timeArray.length > 0) {
@samuelbeek
samuelbeek / order-object-by.js
Created February 3, 2015 09:33
Order Arrays in AngularJS
// order an array
// to use: <div ng-repeat="thing in things | orderTimeObjectBy:'order'">
app.filter('orderObjectBy', function() {
return function(items, field, reverse) {
var filtered = [];
angular.forEach(items, function(item) {
filtered.push(item);
});
filtered.sort(function (a, b) {
class TextView: UITextView {
override init(frame: CGRect) {
super.init(frame: frame)
addContentSizeObserver()
}
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
}
@samuelbeek
samuelbeek / VerticalCenteredTextView.swift
Last active January 6, 2019 23:37
Vertically aligned text in textview
class VerticalCenteredTextView: UITextView {
override init(frame: CGRect) {
super.init(frame: frame)
addContentSizeObserver()
}
override init(frame: CGRect, textContainer: NSTextContainer?) {
super.init(frame: frame, textContainer: textContainer)
}