Skip to content

Instantly share code, notes, and snippets.

View BlaShadow's full-sized avatar
🏠
Working from home

Luis BlaShadow

🏠
Working from home
View GitHub Profile
@BlaShadow
BlaShadow / uriToPAth.java
Created February 28, 2014 12:49
Get Path from uri Java
public String getPath(Uri uriFile){
String[] proj = { MediaStore.Images.Media.DATA };
CursorLoader loader = new CursorLoader(this, uriFile, proj, null, null, null);
Cursor cursor = loader.loadInBackground();
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
@BlaShadow
BlaShadow / InputStream.java
Created February 28, 2014 14:14
InputStream to String
private static String getStringFromInputStream(InputStream inputStream) {
BufferedReader buffer = null;
StringBuilder sb = new StringBuilder();
String line;
try {
buffer = new BufferedReader(new InputStreamReader(inputStream));
while ((line = buffer.readLine()) != null) {
Bitmap BlurImage (Bitmap input)
{
var rsScript = RenderScript.Create (Context);
var alloc = Allocation.CreateFromBitmap (rsScript, input);
var blur = ScriptIntrinsicBlur.Create (rsScript, alloc.Element);
blur.SetRadius (12);
blur.SetInput (alloc);
var result = Bitmap.CreateBitmap (input.Width, input.Height, input.GetConfig ());
@BlaShadow
BlaShadow / test.xml
Created March 2, 2014 14:46
Descripcion
< receiver android:enabled="true" android:name=".broadcast_reciber_class" >
< intent-filter android:priority="1">
< action android:name="android.intent.action.ACTION_SET_WALLPAPER" />
< /intent-filter>
< /receiver>
@BlaShadow
BlaShadow / child.js
Created March 28, 2014 15:59
Child Process nodejs
var context = [];
(function(context){
setInterval(function(){
var value = context.pop()
console.log('iteraciones ' + value);
},1000);
})(context);
process.on('message',function(value){
@BlaShadow
BlaShadow / lol.py
Created April 17, 2014 14:41 — forked from faruken/lol.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from twisted.application import service
from twisted.web import server, static
from twisted.web.resource import Resource
from twisted.web.wsgi import WSGIResource
from twisted.internet import reactor
from flask.views import MethodView
{
"country": {
"iso_code": "CO",
"names": {
"pt-BR": "Colômbia",
"es": "Colombia",
"ru": "Колумбия",
"en": "Colombia",
"zh-CN": "哥伦比亚",
"fr": "Colombie",
#!/bin/sh
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
curl -L https://get.rvm.io | bash -s stable
rvm install 2.0.0
rvm use 2.0.0@global --default
# for chinese user, if you have a wonderful speed ignore this part
# to have a faster download speed
# switch gem source to ruby.taobao.org
describe('/blog', function() {
it('returns blog posts as JSON', function(done) {
api.get('/blog')
.set('x-api-key', '123myapikey')
.auth('correct', 'credentials')
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) return done(err);
@BlaShadow
BlaShadow / url_encode
Last active August 29, 2015 14:02
Url encode
// file "NSDictionary+UrlEncoding.m"
#import "NSDictionary+UrlEncoding.h"
// helper function: get the string form of any object
static NSString *toString(id object) {
return [NSString stringWithFormat: @"%@", object];
}
// helper function: get the url encoded string form of any object
static NSString *urlEncode(id object) {