Skip to content

Instantly share code, notes, and snippets.

View MarcoSero's full-sized avatar

Marco Sero MarcoSero

View GitHub Profile
@MarcoSero
MarcoSero / tips.py
Last active September 14, 2019 19:44
Python's less common constructs and various tips
# Misc python tips from https://book.pythontips.com/en/latest/index.html
###################################################
# *args
def test_var_args(f_arg, *argv):
print("first normal arg:", f_arg)
for arg in argv:
print("another arg through *argv:", arg)
# test_var_args('yasoob', 'python', 'eggs', 'test')
# first with *args
@MarcoSero
MarcoSero / .zshrc
Created November 3, 2015 21:51
Fast git prompt
# Load oh-my-zsh first
source $ZSH/oh-my-zsh.sh
# If we are on a big repo, re-define git prompt
function git_prompt_info() {
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
@MarcoSero
MarcoSero / package-ida.sh
Last active August 29, 2015 14:25 — forked from phatblat/package-ida.sh
A quick script to package up an .ipa correctly since `xcodebuild -exportArchive` misses the required SwiftSupport and WatchKitSupport folders
#!/bin/bash -e
#
# package-ipa.sh
#
# Bundles an iOS app correctly, using the same directory structure that Xcode does when using the export functionality.
#
xcarchive="$1"
output_ipa="$2"
--Authored by Grant Slatton on 2013 October 10
--All code is released to the public domain under the terms of [http://unlicense.org/]
import Data.List
import Control.Monad
import Data.Maybe
import Data.Function
magicSquare = [8,1,6,3,5,7,4,9,2]
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@MarcoSero
MarcoSero / Mantle.podspec.json
Created April 3, 2015 09:27
Mantle.podspec.json
{
"name": "Mantle",
"version": "2.0",
"summary": "Model framework for Cocoa and Cocoa Touch.",
"homepage": "https://github.com/Mantle/Mantle",
"license": "MIT",
"authors": {
"GitHub": "support@github.com"
},
"source": {
+ (UIImage *)decompressedImageWithImage:(UIImage *)image resizeTo:(CGSize)targetSize
{
CGImageRef imageRef = image.CGImage;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
BOOL sameSize = NO;
if (CGSizeEqualToSize(targetSize, CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)))) {
targetSize = CGSizeMake(1, 1);
sameSize = YES;
}
@MarcoSero
MarcoSero / cabal_dash_docset.sh
Created December 9, 2014 15:02
Convert all Cabal documentation to a Dash docset
#!/bin/zsh
arch=x86_64
os=osx
kernel=darwin
compiler=ghc
version=7.8.3
user=~/.ghc/$arch-$kernel-$version/package.conf.d
target=myhaskell.docset
dash_path="~/Library/Application Support/Dash/DocSets/Haskell/"
@MarcoSero
MarcoSero / contacts.hs
Created November 2, 2014 11:21
Simple JSON-backed address book in Haskell
{-# LANGUAGE OverloadedStrings, DeriveGeneric #-}
import Data.Aeson ((.:), (.:?), decode, encode, FromJSON(..), ToJSON(..), Value(..))
import Data.Aeson.Encode.Pretty
import qualified Data.ByteString.Lazy as BS (readFile, writeFile)
import Control.Applicative ((<$>), (<*>))
import Control.Monad.IO.Class
import Control.Monad
@MarcoSero
MarcoSero / .gitconfig
Last active August 29, 2015 14:06
Cleanup merged branches
cleanup = "!git branch --merged | grep -v '\\*\\|master\\|develop' | xargs -n 1 git branch -d"
cleanupr = "!git fetch --prune ; git branch -r --merged | grep origin | grep -v '>' | grep -v '\\*\\|master\\|develop' | xargs -L1 | cut -d"/" -f2- | xargs git push origin --delete"