Skip to content

Instantly share code, notes, and snippets.

View GuillaumeJasmin's full-sized avatar

Guillaume Jasmin GuillaumeJasmin

View GitHub Profile
@GuillaumeJasmin
GuillaumeJasmin / listFontiOS.m
Last active August 29, 2015 14:01
Add custom font in iOS
/**
* Add font to project. In the right side, in "Target Membership", check your project.
* In infos.plist, add "Fonts provided by application" (array), and each item is the font file's name
*/
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
@GuillaumeJasmin
GuillaumeJasmin / GoogleMapsIconMarker.m
Last active April 13, 2023 05:02
iOS GoogleMaps icon marker with image and text
// image
UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 50)];
iconView.image = [UIImage imageNamed:@"my-icon-image"];
// text
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 35, 50)];
label.text = @"test";
[iconView addSubview:label];
// grab it
@GuillaumeJasmin
GuillaumeJasmin / extract.js
Last active September 26, 2022 04:10
Extract substring between two strings
String.prototype.extract = function(prefix, suffix) {
s = this;
var i = s.indexOf(prefix);
if (i >= 0) {
s = s.substring(i + prefix.length);
}
else {
return '';
}
if (suffix) {
@GuillaumeJasmin
GuillaumeJasmin / vim-color
Created February 4, 2014 17:42
vim color
créer un fichier .vimrc dans le dossier du user, y insérer:
:syntax on
pour que ça fonctionne avec sudo, il faut ajouter ce meme fichier à la racine pour le user root
<snippet>
<content><![CDATA[console.log(${1});]]></content>
<tabTrigger>log</tabTrigger>
<scope>source.js</scope>
<description>Génère un console.log()</description>
</snippet>
@GuillaumeJasmin
GuillaumeJasmin / custom.css
Created December 14, 2013 23:22
Chrome dev tools custom Monokai
/**********************************************/
/*
/* SO-Dark-Monokai
/* https://github.com/simonowendesign/SO-Dark-Monokai
/* Taken from the below and tweaked by Simon Owen (@simonowendesign)
/*
/* IR_Dark_Monokai
/* Designed and developed by Andres Pagella (@mapagella)
/* http://www.andrespagella.com/customising-chrome-devtools
/*
@GuillaumeJasmin
GuillaumeJasmin / resizeImg.js
Last active December 30, 2015 11:09
Dirctive AngularJS
app.directive('resizeImg', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var src = attrs.ngSrc;
var maxWidth = attrs.width;
var maxHeight = attrs.height;
var newWidth;
function cleanString (string) {
var find = ['.','"',"'",' ','’',';',',',':','à','á','â','ã','ä','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ú','û','ü','ý','ÿ','À','Á','Â','Ã','Ä','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','Ù','Ú','Û','Ü','Ý'];
var replace = ['','','','-','','','','','a','a','a','a','a','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','u','y','y','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','U','U','U','U','Y'];
var replaceString = string;
var regex;
for (var i = 0; i < find.length; i++) {
regex = new RegExp(find[i], "g");
replaceString = replaceString.replace(regex, replace[i]);
}
replaceString = replaceString.toLowerCase();