Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am andreaj8 on github.
  • I am jay24 (https://keybase.io/jay24) on keybase.
  • I have a public key ASDurg5ksrnhgN8mB4OQE2s9YRQxxIP8BAst52GEXQnaCQo

To claim this, I am signing this object:

@andreaj8
andreaj8 / gmail_auth.js
Last active May 20, 2017 19:55
Gmail Get Auth Token
/*
https://medium.com/@andrea_j24/come-trasformare-le-email-in-richieste-http-84c178480d1f
npm install google-auth-library readline
node gmail_auth.js
*/
var googleAuth = require('google-auth-library');
var readline = require('readline');
// See scopes : https://developers.google.com/gmail/api/auth/scopes
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="20206" android:versionName="2.2.6" package="***********" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN"
@andreaj8
andreaj8 / gist:cc55408a25faeb4d6306
Created September 8, 2015 14:44
parallel count query in one model for single params
// Use MongoDB 3.0 group() function for getting users and count attribute
function countUsersAttributes(_key, _cond) {
var deferred = Q.defer();
db_mongo_driver.users.group({
key: _key,
cond: _cond,
reduce: function (value, result) {
result.count++;
@andreaj8
andreaj8 / gist:f9b4d9864d1220259e5b
Last active August 29, 2015 14:22
Socket Push NodeJs proxy design
[Pagina di testing PHP]
1) PHP serve una pagina munita di un ID univoco (come simulazioned di utente in sessione)
2) La pagina servita si collega ad un server per il socket [server node]
3) la pagina ha un tasto like, che chiama PHP e simula l'operazione di like, dopo di che la pagina PHP fa una chiamata HTTP GET ad un andPoint del server NODE con due parametri GEt : ID, messaggio
[Server NODE]
1) Espone un endpoint
2) Alla ricezine della chiamata manda un messaggio al client ID con il messaggio
<html
xmlns="http://www.w3.org/1999/xhtml">
<head/>
<body>
<svg
xmlns="http://www.w3.org/2000/svg" width="300" height="300">
<g transform="translate(100,100)">
<g class="slice">
<path fill="#3182bd" d="m-95.10565162951534,-30.901699437494813a100,100 0 0,1 7.044874666267686e-14,-100l0,0z"/>
<text transform="translate(-29.38926261462363,-40.45084971874739)" text-anchor="middle">20</text>
json2csv({
data: usersArray,
fields: ['name', 'email', 'gender', 'birthday', 'created', 'address', 'img', 'platform', 'used', 'scratched', 'winning', 'changed', 'welcomeKit', 'gift', 'invalidated', 'games'],
del: ';'
},
function (err, csv) {
if (err) return res.json(500);
res.set({
"Content-Disposition": "attachment; filename=o_o.csv"
});
@andreaj8
andreaj8 / synchronous.js
Last active August 29, 2015 14:07
Node js, Series of http request synchronous
var request = require('request');
var async = require('async');
var array = [];
for (var i = 0; i < 10; i++) {
array.push(function (callback) {
request('www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
@andreaj8
andreaj8 / profile.js
Created January 20, 2014 14:24
Titanium Alloy ( 3.2.0) Table View strange behavior
(function() {
$.save.enabled = false;
var u = user.getCurrent();
$.textFName.value = u.custom_fields ? u.first_name + " " + u.last_name : "";
$.textFphone.value = u.custom_fields ? u.custom_fields.number : "";
$.textFmail.value = u ? u.email : "";
$.profilePic.image = u.photo.urls ? u.photo.urls.small_240 : "sample-img.png";
Alloy.Globals.interestStatus = u.custom_fields ? u.custom_fields.interest : [];
var data = $.table.getData();
@andreaj8
andreaj8 / gist:7092500
Created October 21, 2013 23:21
Target Descriptio
var TargetSchema = mongoose.Schema({
id: Number,
cure: {type:mongoose.Schema.Types.ObjectId, ref:'Cure'},
exercise : String,
startate : Date,
criteria : Array,
endDate : Date,
masterizzationCriteria : Object, //{ numero ripetizioni , %}
// leve:Number, // 0 1 2