Skip to content

Instantly share code, notes, and snippets.

View jlcampana's full-sized avatar
:octocat:
emu emu emu...

Jose Luis Campaña jlcampana

:octocat:
emu emu emu...
View GitHub Profile
@jlcampana
jlcampana / demo
Last active August 29, 2015 14:20
// usage demo:
.block {
width: 100px;
margin: 20px;
height: 100px;
}
.hsl {
background-color: hsl(118, 77%, 53%);
}
.rgb {
@NicolasRitouet
NicolasRitouet / ctx.js
Created February 13, 2015 09:18
Deployd ctx object inside event
{ url: '/e59f6412949f29b9',
req:
{ _readableState:
{ highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: false,
ended: true,
@JohnEstropia
JohnEstropia / JEProgressView.h
Last active October 5, 2023 14:59
Workaround an annoying bug with iOS 7.1 where custom track and progress images for UIProgressView gets ignored
//
// JEProgressView.h
//
//
// Created by John Rommel Estropia on 2014/03/11.
// Copyright (c) 2014 John Rommel Estropia.
//
// 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
@jlcampana
jlcampana / delete_file.m
Created March 7, 2014 15:30
Borrar un fichero
@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t ioQueue;
//...
_ioQueue = dispatch_queue_create("com.currycat.files", DISPATCH_QUEUE_SERIAL);
//...
if (path) {
dispatch_async(self.ioQueue, ^{
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
});
}
// Clamps a block of text to a certain number of lines,
// followed by an ellipsis in Webkit and Blink based browsers
// Reference: http://dropshado.ws/post/1015351370/webkit-line-clamp
@mixin text-clamp($lines: 2, $line-height: false) {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $lines;
// Fallback for non-Webkit browsers
@aras-p
aras-p / preprocessor_fun.h
Last active May 3, 2025 13:47
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@creationix
creationix / jsonparse.js
Last active May 10, 2024 14:36
A streaming JSON parser as an embeddable state machine.
// A streaming byte oriented JSON parser. Feed it a single byte at a time and
// it will emit complete objects as it comes across them. Whitespace within and
// between objects is ignored. This means it can parse newline delimited JSON.
function jsonMachine(emit, next) {
next = next || $value;
return $value;
function $value(byte) {
if (!byte) return;
if (byte === 0x09 || byte === 0x0a || byte === 0x0d || byte === 0x20) {
@jlcampana
jlcampana / gist:5955410
Created July 9, 2013 07:35
Esconder teclado cuando se pulsa Enter y ejecutar algo
- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if([string isEqualToString:@"\n"]) {
[textField resignFirstResponder];
return NO;
}
return YES;
}
@depoulo
depoulo / gist:5832073
Last active January 3, 2025 15:23
CSS-only multi-line ellipsis with generated content. License: http://www.wtfpl.net/txt/copying/
@import "compass/css3/images";
// CSS-only multi-line ellipsis with generated content
// yields `position:relative`, so remember to declare an eventual `position:absolute/fixed` *after* including this mixin
@mixin limitLines(
$maxLinesPortrait, // Mandatory: The number of lines after which the clipping should take action.
$maxLinesLandscape: $maxLinesPortrait, // You may provide a different line limit for landscape orientation.
// Note that 'portrait' is our default orientation. However, if you omit $maxLinesLandscape,
// the value of $maxLinesPortrait is used for whatever orientation (that is, without a media query).
@jlcampana
jlcampana / gist:5487482
Created April 30, 2013 08:52
Escapar URL
NSString *s = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)[[self.app.externalURL absoluteString] mutableCopy], NULL, CFSTR("=,!$&'()*+;@?\n\"<>#\t :/"),kCFStringEncodingUTF8));
url =[NSURL URLWithString:s];