Skip to content

Instantly share code, notes, and snippets.

@fractefactos
fractefactos / load_ajax.js
Created March 7, 2018 11:28 — forked from kalharbi/load_ajax.js
PhantomJS - Load dynamic web page content that uses AJAX
// Original code:
// https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js
// https://github.com/ariya/phantomjs/blob/master/examples/rasterize.js
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
@fractefactos
fractefactos / js-toSlug.js
Created August 29, 2016 06:19 — forked from juanmhidalgo/js-toSlug.js
JavaScript toSlug()
String.prototype.toSlug = function(){
st = this.toLowerCase();
st = st.replace(/[\u00C0-\u00C5]/ig,'a')
st = st.replace(/[\u00C8-\u00CB]/ig,'e')
st = st.replace(/[\u00CC-\u00CF]/ig,'i')
st = st.replace(/[\u00D2-\u00D6]/ig,'o')
st = st.replace(/[\u00D9-\u00DC]/ig,'u')
st = st.replace(/[\u00D1]/ig,'n')
st = st.replace(/[^a-z0-9 ]+/gi,'')
st = st.trim().replace(/ /g,'-');
$.fn.extend({
trackChanges:
function() {
$(':input', this).change(function() {
$(this.form).data('changed', true);
});
$(':textarea', this).change(function() {
$(this.form).data('changed', true);
});
$(':select', this).change(function() {
@fractefactos
fractefactos / pivot_example.php
Last active October 17, 2022 08:47 — forked from lighta971/pivot_example.php
Laravel Custom Pivot Model definition example
<?php
//https://github.com/laravel/framework/issues/2093#issuecomment-39154456
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\Pivot;
class User extends Eloquent {
public function groups() {
return $this->belongsToMany('Group');
@fractefactos
fractefactos / treemap_header_02.html
Last active August 29, 2015 14:27 — forked from billdwhite/treemap_header_02.html
d3 Treemap with Headers Demo
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Treemap - Neat Zoom Effect</title>
<script type="text/javascript" src="./d3/d3.js"></script>
<style type="text/css">
body {
overflow: hidden;
margin: 0;
@fractefactos
fractefactos / index.html
Last active August 29, 2015 14:27 — forked from jasondavies/index.html
RequireJS and D3
<!DOCTYPE html>
<meta charset="utf-8">
<style> body { font-family: sans-serif; } </style>
<body>
<script src="require.js"></script>
<script>
require.config({
paths: {
d3: "http://d3js.org/d3.v3.min"
}
@fractefactos
fractefactos / SassMeister-input-HTML.html
Last active August 29, 2015 14:27
Generated by SassMeister.com.
<h1>SASS RULZ!</h1>
<div class="altura">HEIGHT &nbsp;</div>
<div class="altura-otra">ANOTHER HEIGHT &nbsp;</div>
@fractefactos
fractefactos / SassMeister-input-HTML.html
Created August 2, 2015 04:03
Generated by SassMeister.com.
<h1>LALALALA</h1>
<div class="texto">lalalala</div>
# html5 pushstate (history) support:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L,QSA]
</ifModule>
@fractefactos
fractefactos / designer.html
Last active August 29, 2015 14:18
designer
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>