Skip to content

Instantly share code, notes, and snippets.

function doubleNum(num) {
var
numStr = num + '',
numLen = numStr.length;
if (!(numLen%2)) {
var
first = numStr.substring(0, numLen/2),
second = numStr.substring(numLen/2);
const http = require('http');
const Firebase = require('firebase');
const FB_ROOT = new Firebase('https://scrapyard.firebaseio.com/');
const VK = {
wallGet: {
// translating vk api to node http api
reqOpts: function(opts) {
return({
host: 'api.vk.com',
@lkLeonov
lkLeonov / cons.js
Created April 16, 2016 10:50
Simple Chrome console styling function
// Styling Chrome Console
function cons(styles) {
if (!cons.initial) cons.initial = console;
var defaultStyles = 'font-family: Arial; font-size: 2em;';
styles = styles || defaultStyles;
console = {
log: function(str) { cons.initial.log('%c' + str, styles) }
@lkLeonov
lkLeonov / instaGet
Created July 28, 2016 17:52
How to get media from instagram via XHR
function getMedia(instaData, mediaCount, callback) {
var profileData = instaData.entry_data.ProfilePage[0];
var userID = profileData.user.id;
var totalMedia = profileData.user.media.count;
var mediaCount = mediaCount > totalMedia ? totalMedia : mediaCount;
var csrf_token = instaData.config.csrf_token;
var xhrBody = "ig_user(" + userID + ") { media.after(0, " + mediaCount + ") {nodes {display_src }}}";
var xhr = new XMLHttpRequest();
xhr.open("POST", '/query/', true)
'use strict'
const http = require('http');
const querystring = require('querystring');
const VK = {
'groupId': {
name: 'groups.getById',
group_ids: 'boroda.land'
}
var INVITER = {
//chas: '53a8d957e483483cf5', // unique for specific account //lkleonov
chas: 'e796d178a8fd0c3cfb', // unique for specific account //laukye
message: 'Хей, привет! Меня зовут Алексей. В рамках проекта по объединению креативных людей Constellation, мы запустили кампанию по поиску единомышленников. Мы решили, что если ты вдруг тоже заинтересован в поисках оных, то у меня есть для тебя хорошая новость! Попутно мы можем помочь с поисками единомышленников тебе, если ты в них нуждаешься!\n\nРаботает это так: ставишь тег #constellate на стене (или где-нибудь, чтобы тебя можно было найти через поиск) и рядом теги твоих увлечений, в чём ты, может, разбираешься, можешь свободно обсуждать и делиться опытом, творить что-то (ну, например, вот так: "#art #photography #dogbreeding #webdev #handmade #constellate"). И люди смогут потом находить по тегу #constellate тех, кто тоже находится в поисках и видеть, чем они увлекаются, чтобы завязать общение. Или, чтобы дать своим друзьям понять, о чём речь, можешь
self.addEventListener('message', function(e) {
self.postMessage(e.data);
}, false);
function xhr(xhrMethodName, appendedFunc) {
(function(xhrMethod) {
XMLHttpRequest.prototype[xhrMethodName] = function(data) {
appendedFunc(data);
xhrMethod.call(this.data);
};
})(XMLHttpRequest.prototype[xhrMethodName]);
}
// xhr('send', function(d) {console.log(d)});
'use strict'
const http = require('http');
const querystring = require('querystring');
const PORT = 80;
http.createServer((servReq, servRes) => {
const postData = querystring.stringify({
var xhr = new XMLHttpRequest();
var body = 'act=load_idols&al=1&oid=50595075';
xhr.open("POST", 'https://vk.com/al_fans.php', true)
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText)