Skip to content

Instantly share code, notes, and snippets.

View karlingen's full-sized avatar
🏂
\o/

Karl Metum karlingen

🏂
\o/
View GitHub Profile
@n1snt
n1snt / Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md
Last active April 23, 2024 17:16
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

require 'fileutils'
require 'optimist'
require 'plist'
def run(path, source_path)
process(path, source_path, '**/*.app', true)
process(path, source_path, '**/*.dylib', false)
end
def process(path, source_path, search_pattern, is_app)
@ilyapuchka
ilyapuchka / StickyLayout.swift
Last active February 25, 2024 18:43
Really sticky collection view layout
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
super.init()
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
}
@jgold6
jgold6 / gist:a1e60e0bb24ccdd2b2b8
Last active April 17, 2023 05:28
Xamarin Reduce App Size
* Reducing executable size:
http://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/#Reducing_Executable_Size
* Use the linker (iOS [1], Android [2]) to remove unnecessary code from your assemblies
[1] https://developer.xamarin.com/guides/ios/advanced_topics/linker
[2] https://developer.xamarin.com/guides/android/advanced_topics/linking
* Reference third-party libraries judiciously
* Applying constraints to generics may reduce app size, since less code would need to be included (haven’t verified this)
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 15, 2022 12:35 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@cmoulton
cmoulton / UISwiftRestDemo
Last active September 9, 2021 21:01
Quick & dirty REST API calls with Swift 2.2. See http://grokswift.com/simple-rest-with-swift/
// MARK: Using NSURLSession
// Get first todo item
let todoEndpoint: String = "http://jsonplaceholder.typicode.com/todos/1"
guard let url = NSURL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = NSURLRequest(URL: url)
@fotinakis
fotinakis / cancan_matchers.rb
Last active December 8, 2023 14:18
Custom rspec matcher for testing CanCan abilities
# Custom rspec matcher for testing CanCan abilities.
# Originally inspired by https://github.com/ryanb/cancan/wiki/Testing-Abilities
#
# Usage:
# should have_abilities(:create, Post.new)
# should have_abilities([:read, :update], post)
# should have_abilities({manage: false, destroy: true}, post)
# should have_abilities({create: false}, Post.new)
# should not_have_abilities(:update, post)
# should not_have_abilities([:update, :destroy], post)
@hopsoft
hopsoft / db.rake
Last active April 3, 2024 13:13
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@umidjons
umidjons / bootstrap-cmenu-yii.php
Created February 24, 2014 08:22
Use bootstrap menu in Yii with CMenu
<nav class="navbar navbar-default top-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex-collapse">
<span class="sr-only">Expand the menu</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-ex-collapse">
<?php
/**
* I18N class for translating text to any language
* Uses YAML files
*
* Usage: I18N::t("user.name") # => "Karl Metum"
* In the above example "name" is nested under "user"
*
* Make sure that the following constants are set in
* your configuration file: