Skip to content

Instantly share code, notes, and snippets.

View ShantiSR's full-sized avatar

Shanti Rodríguez ShantiSR

View GitHub Profile
@ShantiSR
ShantiSR / gist:d4e815ec44bdef06c66833303b32c08f
Created August 30, 2016 07:23
PHP - Convert date string to Twitter format
<?php
$return = '';
$date = strtotime($date);
$diff = time() - $date;
if ($diff < 86400) {
if ($diff < 3600) { // Output e.g. 35 minutes ago
$return = $mins = floor($diff / 60);
$return .= ' minute';
if ($mins > 1 || $mins === 0) $return .= 's';
@ShantiSR
ShantiSR / gist:196871685b168a4a889e
Created February 26, 2016 08:26 — forked from bergholdt/gist:0db2d2264e29e3646e9c
Rotate UIBarButtonItem
-(void)startAnimationUIBarButtonItem:(UIBarButtonItem *)buttonItem
{
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear animations:^{
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI);
UIView *view = [buttonItem valueForKey:@"view"];
view.transform = transform;
} completion:NULL];
}
-(void)stopAnimationUIBarButtonItem:(UIBarButtonItem *)buttonItem
@ShantiSR
ShantiSR / UIButtonBox.h
Created February 8, 2016 09:12 — forked from jalopezsuarez/UIButtonBox.h
UIButtonBox
//
// UIButtonBox.h
//
// Created by Jose Antonio Lopez on 28/11/13.
// Copyright (c) 2014 Asenit Technologies SL. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIButtonBox : UIButton
@ShantiSR
ShantiSR / appetize.js
Created January 25, 2016 16:07 — forked from Shanti-SR/appetize.js
Eliminar el limite de tiempo de appetize.io Pegar el código en la consola del navegador.
var $body = angular.element(document.body);
var $rootScope = $body.injector().get('$rootScope');
setInterval(function(){
$rootScope.devices[0].appetizer.emit("userInteraction", {type: "heartbeat"});
}, 1000);
@ShantiSR
ShantiSR / StringSize.swift
Created September 24, 2015 19:04 — forked from plumhead/StringSize.swift
String extension to find the layout size of a String with specified attributes.
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
layout.addTextContainer(container)
storage.addLayoutManager(layout)
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)
@ShantiSR
ShantiSR / css
Last active August 29, 2015 14:26 — forked from CodeMyUI/css
Sign In/Up Transition By Fabrizio Bianchi : http://codepen.io/fbrz/pen/pvZRNK
@import url(http://fonts.googleapis.com/css?family=Raleway:700,800);
html, body { margin: 0; }
:focus { outline: none; }
::-webkit-input-placeholder { color: #DEDFDF; }
::-moz-placeholder { color: #DEDFDF; }
:-moz-placeholder { color: #DEDFDF; }
::-ms-input-placeholder { color: #DEDFDF; }
import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
/**
* @author Miguel Catalan Bañuls
/**
* Include Roboto Condensed font in your project
*
* Download Roboto Condensed ttf files from Google Fonts and place it in the same directory of this CSS file
* You can then use this font in your project by setting
* font-face: "Roboto Condensed", Helvetica, Arial, sans-serif;
*
* @author Mattia Migliorini (deshack)
* @license MIT
*/
@ShantiSR
ShantiSR / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/*
* At its core, Backstretch is a one-line plugin.
* Just pass in the path to an image, and you're done.
*/
$.backstretch("http://dl.dropbox.com/u/515046/www/garfield-interior.jpg");