Skip to content

Instantly share code, notes, and snippets.

View Sumolari's full-sized avatar

Lluís Ulzurrun de Asanza Sàez Sumolari

View GitHub Profile
@Sumolari
Sumolari / Máquina contador (Swift)
Last active August 29, 2015 14:02
Intérprete de código de máquina contador
class Memoria {
var r = Dictionary<String,Int>()
func suc( i:String ) -> Int {
self.r[ i ] = ( self.r[ i ]? ) ? self.r[ i ]! + 1 : 1
return self.r[ i ]!
}
func pre( i:String ) -> Int {
let ret = ( self.r[ i ]? ) ? self.r[ i ]! - 1 : -1
self.r[ i ] = ( self.r[ i ]? && self.r[ i ] > 0 ) ? self.r[ i ]! - 1: 0
return ret
@Sumolari
Sumolari / List fonts
Created July 17, 2014 13:51
Lists available fonts with Swift
var fns = UIFont.familyNames()
for ( var iF = 0; iF < fns.count; ++iF ) {
println( "Family name: " + ( fns[ iF ] as String ) )
var fontns = UIFont.fontNamesForFamilyName( ( fns[ iF ] as String ) )
for ( var iFN = 0; iFN < fontns.count; ++iFN ) {
println( "\tFont name: " + ( fontns[ iFN ] as String ) )
}
}
@Sumolari
Sumolari / Sudoku Backtracking
Last active August 29, 2015 14:12
Program to solve a Sudoku using simple backtracking
import sys
import curses
def sudoku(grid):
global times
global row_cache
global col_cache
times = 0
@Sumolari
Sumolari / installDS.sh
Last active August 29, 2015 14:14
Instalar toolkit Nintendo DS
# Instalar mis herramientas de terminal favoritas.
# sudo apt-get update -qy
# sudo apt-get upgrade -qy
# sudo apt-get install vim git curl zsh git-core wget -qy
# wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
# chsh -s `which zsh`
# Necesario para poder instalar el Toolkit de Nintendo DS
sudo dpkg --add-architecture i386
@Sumolari
Sumolari / 12184
Last active August 29, 2015 14:17
12184
#include <iostream>
#include <vector>
#define INFINITY 9E18
#define IMPOSSIBLE "impossible"
using namespace std;
typedef vector<long long> vll;
@Sumolari
Sumolari / INSTALL.md
Last active August 29, 2015 14:22 — forked from sztupy/INSTALL.md

rage-quit plugin for oh-my-zsh

based on rage-quit support for bash

HOW TO INSTALL

Put the files below inside ~/.oh-my-zsh/custom/plugins/fuck

Also chmod a+x the flip command.

@Sumolari
Sumolari / default
Last active December 12, 2015 19:02
Deny access to WordPress xmlrpc.php in nginx
# BEGIN protect xmlrpc.php
location = /xmlrpc.php {
deny all;
}
# END protect xmlrpc.php
@Sumolari
Sumolari / increase-xcode-build-number.sh
Created February 8, 2016 08:49
Increases Xcode build number
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
@Sumolari
Sumolari / game.cpp
Last active May 2, 2019 22:13
Set texture wrap mode in Cocos2d-x
cocos2d::Texture2D::TexParams texParams = {
GL_NEAREST, // TextureMinFilter
GL_NEAREST, // TextureMagFilter
GL_CLAMP_TO_EDGE, // TextureWrapMode Horizontal
GL_CLAMP_TO_EDGE // TextureWrapMode Vertical
};
this->getTexture()->setTexParameters( texParams );
@Sumolari
Sumolari / demo_kvdatabase.cpp
Created April 18, 2016 16:11
Checks if player has enough money to buy an item, and buys it if possible
#include "MawKit/KVDatabase.hpp"
bool buyIfPossible( long long price )
{
constexpr const char *moneyKey = "money";
if ( MK::KVDatabase::getLongValueForKey( moneyKey ) > price ) {
MK::KVDatabase::decreaseLongValueForKey( moneyKey, price );
return true;
}