Skip to content

Instantly share code, notes, and snippets.

@anjerodesu
anjerodesu / ReindexSpotlight.sh
Created December 27, 2012 03:27
This is a Spotlight reindexing script for Mac. If you have problems such as your Mac is always indexing your HDDs or the indexing process always crashes.
#!/bin/bash
# This is a Spotlight reindexing script for Mac.
# If you have problems such as your Mac is always indexing your HDDs
# or the indexing process always crashes.
# turn off all mounted volumes
# remove -a to apply only on current volume
# -a : apply command to all volumes
sudo mdutil -a -i off
@anjerodesu
anjerodesu / DBClass.php
Last active September 23, 2022 05:13
DBClass is a simple PHP database class using MySQL Improved Extension.
<?php
/********************************************************************************************/
/* DBClass created by Angelo Villegas [http://www.studiovillegas.com] */
/* */
/* Copyright © Angelo Villegas */
/* Permission is hereby granted, free of charge, to any person obtaining a copy of this */
/* software and associated documentation files (the "Software"), to deal in the Software */
/* without restriction, including without limitation the rights to use, copy, modify, */
/* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to the following */
@anjerodesu
anjerodesu / ImageHelper.php
Last active December 10, 2015 22:29
A simple PHP class that with 2 main functions: copy an image from a website to the server and resize and crop the image to the specified size.
<?php
/********************************************************************************************/
/* ImageHelper created by Angelo Villegas [http://www.angelovillegas.com] */
/* */
/* Copyright © Angelo Villegas */
/* Permission is hereby granted, free of charge, to any person obtaining a copy of this */
/* software and associated documentation files (the "Software"), to deal in the Software */
/* without restriction, including without limitation the rights to use, copy, modify, */
/* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to the following */
@anjerodesu
anjerodesu / UPPEValidator.php
Last active December 10, 2015 22:29
UPPEValidator is a simple PHP class that will help validate email addresses, URLs, passwords, and phone numbers.
<?php
/********************************************************************************************/
/* UPPEValidator created by Angelo Villegas [http://www.studiovillegas.com] */
/* */
/* Copyright © Angelo Villegas */
/* Permission is hereby granted, free of charge, to any person obtaining a copy of this */
/* software and associated documentation files (the "Software"), to deal in the Software */
/* without restriction, including without limitation the rights to use, copy, modify, */
/* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to the following */
<?php
/********************************************************************************************/
/* HTMLSpecialEntity created by Angelo Villegas [http://www.studiovillegas.com] */
/* */
/* Copyright © Angelo Villegas */
/* Permission is hereby granted, free of charge, to any person obtaining a copy of this */
/* software and associated documentation files (the "Software"), to deal in the Software */
/* without restriction, including without limitation the rights to use, copy, modify, */
/* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to the following */
@anjerodesu
anjerodesu / README.md
Created March 1, 2013 10:42
A comprehensive script for Xcode projects that lets you generate .gitignore and .gitattributes in the directory of your choosing.

Generate Git

A comprehensive script for Xcode projects that lets you generate .gitignore and .gitattributes in the directory of your choosing.

Running the script

  • Copy the script to your project folder.
  • Open Terminal and run:
    • cd path/to/your/project/ (if you're not yet on your project's directory)
  • sh generate-git.sh
@anjerodesu
anjerodesu / build.sh
Created February 26, 2014 09:48
Auto increment 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"
@anjerodesu
anjerodesu / todo.sh
Last active May 25, 2016 03:33
Run Script that converts certain keywords into a shell warning.
KEYWORDS="TODO:|FIXME:|REMINDER:|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
string trmwsp(string s) {
if (strlen(s) < 1) {
return empstr();
}
while (isspace(*s)) s++;
if (*s == 0) {
return empstr();
extension String {
static func random(length: Int) -> String {
let base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var randomString: String = ""
for _ in 0..<length {
let randomValue = Int.random(from: 0, to: base.characters.count)
randomString.append(base[base.startIndex.advancedBy(randomValue)])
}