Skip to content

Instantly share code, notes, and snippets.

@lu1s
lu1s / bitso_ticker_btcmxn.sh
Last active December 7, 2017 16:12
Run this script to get updated BTC price in MXN pesos. If it raises it prints green, if lowers, red, and if stays the same it won't print until it gets a new one. It requires python to parse the json response. It checks every 3 seconds.
#!/bin/bash
function get_json_val () {
python -c "import json,sys;sys.stdout.write(json.dumps(json.load(sys.stdin)$1))";
}
function print_red () {
printf "\033[0;31m$1\033[0m"
echo ""
}
function print_green () {
@lu1s
lu1s / RandomStringHelper.cs
Created July 11, 2013 18:48
Random string c# static method and its enum
// Use it like:
// RandomStringHelper.RandomString(32, EnumRandomStringType.AlphaNumericWithSymbols);
// and it should return a string like "nd#9ian@iddjhn*And08183Anqov3a8Z"
public class RandomStringHelper
{
private enum EnumRandomStringType
{
AlphaNumeric = 1,
Numbers = 2,
Letters = 3,
@lu1s
lu1s / objeq.js
Created April 11, 2012 18:52
javascript object equality
// y and x can be whatever you look for equality
function objeq(y,x)
{
var p;
for(p in y) {
if(typeof(x[p])=='undefined') {return false;}
}
for(p in y) {
if (y[p]) {
@lu1s
lu1s / charCount_prevent.js
Created March 24, 2012 21:04
jQuery Character Count Plugin with preventExceeding extension
/*
* Character Count Plugin - jQuery plugin
* Dynamic character count for text areas and input fields
* written by Alen Grakalic
* http://cssglobe.com/post/7161/jquery-plugin-simplest-twitterlike-dynamic-character-count-for-textareas
*
* Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
@lu1s
lu1s / get-random-flickr-user-pic-jquery.js
Created March 17, 2012 17:21
Get random flickr picture from given user id and append to given div id (needs jquery and flickr api key)
function getPicture(the_user_id, your_div_id){
var apiKey = "YOUR-API-KEY"; // replace this with your API key
var url_to_a_photo_head = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key="+apiKey+"&photo_id=";
var url_to_a_photo_tail = "&format=json&jsoncallback=?";
// get an array of random photos
$.getJSON(
"http://api.flickr.com/services/rest/",
@lu1s
lu1s / gmaps-quick-addr-map.js
Created September 7, 2011 05:50
google maps quick address map
/*
* Google Maps Quick Address Map
* This snippet gets an address (parameter a)
* and plots a Google Map with a centered
* marker in the id-given element (parameter e)
*
* You need to add the Google Maps V3 API to your site:
* <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
*
* Enjoy!
@lu1s
lu1s / jquery-message-bar.js
Created July 7, 2011 00:14
jQuery Message Bar
/*
* jQuery Message Bar
* @author Luis Pulido <luis@luispulido.com>
* @params:
* what: String, the message to be displayed
* time (optional): Number, the time in milliseconds the bar will
* stay displaying. Default is 2000 ms
* opts (optional): Object, some optional values to customize the bar:
* - height: default 20px
* - fontSize: default 14px
@lu1s
lu1s / jquery-alert-hack.js
Created June 27, 2011 07:18
jQuery alert() beautify and more user friendly
/*
* This function replaces the javascript native alert() function.
* I know that by convention it's not a good practice, but if you want to
* follow strict stuff, just declare the function with another name and
* call it as that.
*
* jQuery.js is required (http://jquery.com)
*
* The function can be called like this:
* For static (not auto-hide) alert bar:
@lu1s
lu1s / cookie-handler.js
Created May 16, 2011 06:53
javascript cookie handler