Skip to content

Instantly share code, notes, and snippets.

View leocaseiro's full-sized avatar
💭
I',m probably studying...

Leo Caseiro leocaseiro

💭
I',m probably studying...
View GitHub Profile
@leocaseiro
leocaseiro / problems.js
Created June 18, 2015 09:18
Frontend Masters - Javascript: The Good Parts by Douglas Crockford
/*
* @link https://frontendmasters.com/courses/javascript-the-good-parts/
Problems 1-5
A sequence of problems will be presented followed by a solution. Each problem builds on the last so if you get a problem wrong, use the solution to begin the next problem. First, a quick quiz: What is x?
3:19:33 - 3:32:25
Problems 6-9
o Problem 6: Write a function that takes a function and an argument, and returns a function that can supply a second argument.
o Problem 7: Without writing any new functions, show three ways to create the inc function.
o Problem 8: Write methodize, a function that converts a binary function to a method.
o Problem 9: Write demethodize, a function that converts a method to a binary function.
@leocaseiro
leocaseiro / .htaccess
Last active February 23, 2022 03:59
Angular html5Mode apache working in a subdirectory /app using ngRoute
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /app/index.html [NC,L]
</IfModule>
@leocaseiro
leocaseiro / angular-directive.html
Created May 15, 2015 01:27
Angular Create Custom Directive
<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<title>Angular Create Directive</title>
</head>
<body>
<div ng-controller="Example">
<button click="click()">click here</button>
<clicker go-click="click()">I am a transcluder</clicker>
</div>
@leocaseiro
leocaseiro / angular-custom-filter.html
Last active August 29, 2015 14:21
Angular Custom Filter
<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<title>Angular Custom Filter</title>
</head>
<body>
<div ng-controller="Filter">
<p>{{text | clean:'-':'.jpg'}}</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
@leocaseiro
leocaseiro / bath.svg
Created May 7, 2015 05:11
SVG Bath
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@leocaseiro
leocaseiro / plugins-list
Last active February 27, 2016 20:35
Sublime Text Plugins
AdvancedNewFile
Alignment
Autoprefixer(css3)
Color Highlitgther (show the color on mouse over)
DocBlockr (For Documentation PHPDocs, CSSDocs, JSDocs...)
Emmet
File Diffs
Git Conflict Resolver (very useful to identify where's the conflict in your file)
HTML-CSS-JS Prettify (minify files .min)
Minifier( Same as above)
@leocaseiro
leocaseiro / pre-commit
Created February 27, 2015 01:16
Syntax check your PHP before GIT Commit
#.git/hooks/pre-commit
#chmod +x pre-commit
#http://www.phil-barker.com/2013/07/syntax-check-your-php-before-git-commit/
#!/usr/bin/php
<?php
// Grab all added, copied or modified files into $output array
exec('git diff --cached --name-status --diff-filter=ACM', $output);
foreach ($output as $file) {
$fileName = trim(substr($file, 1));
@leocaseiro
leocaseiro / validate_currency.php
Created February 19, 2015 23:16
RegEx Currency PHP $1,000,000.00
<?php
/**
* Check if value is currency $value
*
* Pass on:
* 1,000,000.00
* 10,000.00
* 1,000.00
* 100.00
@leocaseiro
leocaseiro / custom-comments-pagination.php
Created January 23, 2015 05:29
Comments Pagination WordPress
<?php
$comments_per_page = 2;
$page = 2;
//MYSQL: LIMIT offset, number
$params = array(
'post_id' => $post_id,
'offset' => (--$page) * $comments_per_page,
'number' => $comments_per_page,
);
@leocaseiro
leocaseiro / metabox-table.html
Created October 20, 2014 03:48
Metabox Table HTML Form example
<table class="form-table">
<tbody>
<tr>
<th scope="row"><label>Example:</label></th>
<td>
<select name="select-name-whenever">
<option>1</option>
<option>lorem</option>
</select>
</td>