Skip to content

Instantly share code, notes, and snippets.

Avatar
💙
reacting

Eduardo P. Rivero eperedo

💙
reacting
View GitHub Profile
@eperedo
eperedo / validation.js
Created Aug 24, 2012
jQuery Validation 1.9 for twitter bootstrap 2.1
View validation.js
jQuery.validator.setDefaults({
validClass: "success",
errorElement: "span",
errorPlacement: function(error, element){
$(error).addClass('help-block').insertAfter(element);
},
highlight: function(element, errorClass, validClass) {
$(element).parents('div.control-group').addClass(errorClass).removeClass(validClass);
},
unhighlight: function(element, errorClass, validClass) {
@eperedo
eperedo / angular-analytics.js
Created Dec 27, 2012
Integrating google analytics with angularjs
View angular-analytics.js
//Put this code in the main controller
$scope.$on('$viewContentLoaded', function(event) {
$window._gaq.push(['_trackPageview', $location.path()]);
});
@eperedo
eperedo / DbConfig.cs
Created May 24, 2013
Example Servicestack OrmLite Blob Text Objects
View DbConfig.cs
public class DbConfig
{
public readonly string ConnectionString = ConfigurationManager.ConnectionStrings["TestDb"].ConnectionString;
public readonly OrmLiteConnectionFactory DbFactory;
public DbConfig()
{
DbFactory = new OrmLiteConnectionFactory(ConnectionString, PostgreSqlDialect.Provider);
}
@eperedo
eperedo / app.js
Created Jun 5, 2013
AngularJs Directive for ladda buttons - https://github.com/hakimel/Ladda
View app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $timeout) {
$scope.save = function(){
$scope.loading = true;
$timeout(function(){
$scope.loading = false;
}, 3000);
};
@eperedo
eperedo / guid.js
Created Jun 6, 2013
Generate a guid in javascript
View guid.js
var generateGuid = function(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0,v=c=='x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
}
console.log(generateGuid());
@eperedo
eperedo / url.js
Created Jun 20, 2013
Url filter for angularjs
View url.js
angular.module('ddsiteApp').filter('url', ['$location', function ($location) {
return function (subUrl, parameter) {
var protocol = window.location.protocol,
host = window.location.host,
pathName = window.location.pathname;
if(pathName === '/') {
}
console.log(protocol + '//' + host + '/#/' + subUrl + '/' + parameter);
return protocol + '//' + host + '/#/' + subUrl + '/' + parameter;
@eperedo
eperedo / peru-congressmen.py
Created Jul 11, 2013
Get congressman list
View peru-congressmen.py
import urlfetch
from bs4 import BeautifulSoup
url = "http://www.congreso.gob.pe/organizacion/pleno.asp?mode=Pleno"
response = urlfetch.get(url)
htmlContent = response.content
soup = BeautifulSoup(htmlContent)
dumped = soup.find(id="frmPleno").findAll("table")[2].findAll("tr")
for item in dumped:
if item.find('a'):
print item.find('a')['href'].replace("FichaCongresista.asp?C_Persona=", "")
@eperedo
eperedo / directive.js
Created Jul 22, 2013
Angular directive for static google maps using [gmaps](hpneo.github.io/gmaps/)
View directive.js
angular.module('Your_Name_App').directive('staticMap', [function () {
return {
restrict: 'A',
template: '<a href="{{mapUrl}}" target="_blank"><img src="{{mapUrl}}" /></a>',
replace: true,
scope: {
position: '=position',
},
link: function postLink(scope, element, attrs, controller) {
var generateStaticMap = function() {
@eperedo
eperedo / ladda.js
Created Jul 25, 2013
Directive for ladda buttons
View ladda.js
'use strict';
angular.module('buttonsApp').directive('ladda', ['$timeout', function ($timeout) {
return {
restrict: 'A',
scope: {
stop: '=stop'
},
link: function postLink(scope, element, attrs) {
var l = Ladda.create(element[0]);
View meeting.json
{
"name": "Daily Meeting",
"organization_id" : 1,
"start_date" : "11/2/2013"
"content" : [
{
"question" : "Question Number 1?",
"answer" : "Answer number 1"
},
{
You can’t perform that action at this time.