Skip to content

Instantly share code, notes, and snippets.

View eperedo's full-sized avatar
🎲
remote only

Eduardo Peredo Rivero eperedo

🎲
remote only
View GitHub Profile
@eperedo
eperedo / validation.js
Created August 24, 2012 02:12
jQuery Validation 1.9 for twitter bootstrap 2.1
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 December 27, 2012 02:05
Integrating google analytics with angularjs
//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 02:30
Example Servicestack OrmLite Blob Text Objects
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 June 5, 2013 20:50
AngularJs Directive for ladda buttons - https://github.com/hakimel/Ladda
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 June 6, 2013 03:18
Generate a guid in javascript
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 June 20, 2013 23:55
Url filter for angularjs
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 July 11, 2013 17:54
Get congressman list
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 July 22, 2013 01:38
Angular directive for static google maps using [gmaps](hpneo.github.io/gmaps/)
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 July 25, 2013 02:46
Directive for ladda buttons
'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]);
@eperedo
eperedo / meeting.json
Created November 3, 2013 03:23
Meeting json v1
{
"name": "Daily Meeting",
"organization_id" : 1,
"start_date" : "11/2/2013"
"content" : [
{
"question" : "Question Number 1?",
"answer" : "Answer number 1"
},
{