Skip to content

Instantly share code, notes, and snippets.

View joseadrian's full-sized avatar

Joseadrian Ochoa joseadrian

View GitHub Profile
@joseadrian
joseadrian / responsive_likebox.html
Created October 27, 2015 09:29
Responsive Facebook Like Box
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<div id="container" style="width:100%;">
<div class="fb-like-box" data-href="https://www.facebook.com/adobegocreate" data-width="292" data-show-faces="true" data-stream="true" data-header="true"></div>
</div>
<?php
var_dump (
array_combine(['r','g','b'], sscanf('FF0000', "%02x%02x%02x"))
);
@joseadrian
joseadrian / validate-selectize-fields.js
Created October 2, 2015 03:33 — forked from yannleretaille/validate-selectize-fields.js
How to validate selectize.js comboboxes with the jQuery validation plugin
//How to validate selectize.js comboboxes with the jQuery validation plugin
//selectize.js: http://brianreavis.github.io/selectize.js/ (brianreavis/selectize.js)
//http://jqueryvalidation.org (jzaefferer/jquery-validation)
//configure jquery validation
$("#commentForm").validate({
//the default ignore selector is ':hidden', the following selectors restore the default behaviour when using selectize.js
//:hidden:not([class~=selectized]) | selects all hidden elements, but not the original selects/inputs hidden by selectize
//:hidden > .selectized | to restore the behaviour of the default selector, the original selects/inputs are only validated if their parent is visible
//.selectize-control .selectize-input input | this rule is not really necessary, but ensures that the temporary inputs created by selectize on the fly are never validated
@joseadrian
joseadrian / console-query.php
Created August 24, 2015 23:08
Log queries in console
<?php
Event::listen('illuminate.query', function($query, $binding, $time, $connections)
{
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach ($backtrace as $trace) {
if(array_key_exists('file',$trace) && array_key_exists('line',$trace)){
if( strpos($trace['file'],base_path().'/app') !== false ){
PhpConsole\Handler::getInstance()->debug([
@joseadrian
joseadrian / red-green.js
Created August 5, 2015 08:16
From red to green
var percentColors = [
{ pct: 0.0, color: { r: 0xff, g: 0x00, b: 0 } },
{ pct: 0.5, color: { r: 0xff, g: 0xff, b: 0 } },
{ pct: 1.0, color: { r: 0x00, g: 0xff, b: 0 } } ];
var getColorForPercentage = function(pct) {
for (var i = 0; i < percentColors.length; i++) {
if (pct <= percentColors[i].pct) {
var lower = percentColors[i - 1] || { pct: 0.1, color: { r: 0x0, g: 0x00, b: 0 } };
var upper = percentColors[i];
@joseadrian
joseadrian / phpstorm-auto-semicolon-macro.txt
Last active August 29, 2015 14:26 — forked from umidjons/phpstorm-auto-semicolon-macro.txt
PhpStorm: Record Auto semicolon macro and bind shortcut to it
Record Auto semicolon macro and bind shortcut to it:
1. Edit -> Macros -> Start Macro Recording
2. In the editor go to the end of line by pressing End
3. put semicolon ';'
4. Edit -> Macros -> Stop Macro Recording
5. Give a name, for example 'Auto semicolon'
6. Open settings (Ctrl + Alt + s), select Keymap
7. Expand Macros node
8. Select 'Auto semicolon', in the context menu choose Add Keyboard Shortcut
9. Set Ctrl + ; as First keystroke
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<!--
Remove automatic format detection
I personally love that a lot of clients, especially on mobile, automatically convert dates, phone numbers, and emails to links; however, there’s always that random use case where you might not want to have that happen. Here’s how you can stop it:
// This function creates a new anchor element and uses location
// properties (inherent) to get the desired URL data. Some String
// operations are used (to normalize results across browsers).
function parseURL(url) {
var a = document.createElement('a');
a.href = url;
return {
source: url,
protocol: a.protocol.replace(':',''),
@joseadrian
joseadrian / frontend-guidelines.md
Created February 27, 2015 18:16
Some HTML, CSS and JS best practices. Source: @bendc/frontend-guidelines

Frontend Guidelines

HTML

Semantics

HTML5 provides us with lots of semantic elements aimed to describe precisely the content. Make sure you benefit from its rich vocabulary.

<!-- bad -->
.directive('numbersOnly', function () {
return {
restrict: 'A',
link: function (scope, elm, attrs, ctrl) {
// record ctrl key being down for ctrl+v and ctrl+c
var ctrlDown = false;
// reset the ctrl key flag on keyup
elm.on('keyup', function (event) {
ctrlDown = false;
});