Skip to content

Instantly share code, notes, and snippets.

View samuelbeek's full-sized avatar

Samuel Beek samuelbeek

View GitHub Profile
@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 / 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 / generateCode.swift
Created April 29, 2015 07:39
Generate 4 digit code in Swift
// Verification code is at least for digit long
let verificationCode = String(1000+arc4random_uniform(8999))
@samuelbeek
samuelbeek / movieService.js
Last active August 29, 2015 14:20
MovieService to use OMDB API with Angular
// movieService can be used in a controller like this:
// movieService.getMovieDetails("Pulp Fiction").success(function (data) {
// $scope.movie = data
// }
app.factory('movieService', ['$http', function ($http) {
return {
getMovieDetails: function (title) {
var getData = {
method: 'jsonp',
url: 'http://www.omdbapi.com/?t=' + title, //add +'&apikey=YOUR_API_KEY' if you have one.
@samuelbeek
samuelbeek / DistanceHelper.swift
Created May 1, 2015 11:41
Distance Formatter for Swift
//
// DistanceHelper.Swift
// Wildcard
//
// Created by Samuel Beek on 01-05-15.
// Copyright (c) 2015 Wildcard. All rights reserved.
//
import Foundation