Skip to content

Instantly share code, notes, and snippets.

View IPRIT's full-sized avatar
💅

Alexander Belov IPRIT

💅
View GitHub Profile
var http = require('http');
var bl = require('bl');
module.exports = function(url, callback) {
var result = '';
http.get(url, function(res) {
res.setEncoding('utf8');
res.pipe(bl(function(err, data) {
result += data.toString();
var args = process.argv.slice(2);
var httpPipe = require('./http_pipe');
httpPipe(args[0], function(err, data) {
if (err) throw err;
console.log(data.length);
console.log(data);
});
@IPRIT
IPRIT / program.js
Created April 11, 2015 00:05
Example Get with HTTP
var args = process.argv.slice(2);
var httpGet = require('./http_get');
httpGet(args[0], function(err, data) {
if (err) throw err;
console.log(data);
});
var http = require('http');
module.exports = function(url, callback) {
http.get(url, function(res) {
res.setEncoding('utf8');
res.on('data', function(buf) {
callback(null, buf.toString());
});
#!/bin/sh
basedir=`dirname "$0"`
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../jade/bin/jade.js" "$@"
ret=$?
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
@IPRIT
IPRIT / gist:48e5a0b2961875a96f03
Last active August 29, 2015 14:17
HttpAsyncTask.fragment
public class HttpAsyncTask extends AsyncTask<URL, Integer, String> {
/**
* <URL, Integer, String> — URL::URL, Progress Report::Integer, Result::String
*/
private final String LOG_TAG = TestAsyncTask.class.getSimpleName();
public static final String POST_REQUEST_NAME = "POST";
public static final String GET_REQUEST_NAME = "GET";
@IPRIT
IPRIT / gist:34193b6218201bb9d582
Created March 25, 2015 18:10
Example ResponseParser
package ru.twosphere.android.misisbooks;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by Александр on 31.01.2015.
@IPRIT
IPRIT / Example
Last active August 29, 2015 14:17
using AsyncTask and Uri.Builder
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
else if (match[4]) { // URL & e-mail
if (!options.noLinks) {
var matchEmojiInURL;
if (match[4].match(emojiRegex)) {
if (matchEmojiInURL = match[4].match(emojiRegex)) {
if ((emojiCode = emojiMap[matchEmojiInURL[0]]) &&
(emojiCoords = getEmojiSpritesheetCoords(emojiCode))) {
emojiTitle = encodeEntities(emojiData[emojiCode][1][0]);
emojiFound = true;