Skip to content

Instantly share code, notes, and snippets.

View josejaguirre's full-sized avatar
🤺
Programming

José Aguirre josejaguirre

🤺
Programming
View GitHub Profile
@up1
up1 / build.gradle
Created January 7, 2016 03:40
Android Library with Artifactory
apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
def packageName = 'codeinputlib'
def libraryVersion = '1.0.0'
buildscript {
repositories {
jcenter()
@gbabiars
gbabiars / Scores.js
Created December 20, 2015 21:15
Basic example of RxJS and React
import React from 'react';
import axios from 'axios';
import Rx from 'rxjs';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
scores: []
};
@alexpchin
alexpchin / socket-cheatsheet.js
Created December 15, 2015 16:58
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@farrokhi
farrokhi / postfix-rbl.md
Last active July 22, 2021 04:07
Current Effective RBL Setup for Postfix

Current Effective RBL Setup for Postfix

main.cf:

    smtpd_recipient_restrictions =
      permit_mynetworks,
      permit_sasl_authenticated,
      reject_non_fqdn_hostname,
      reject_non_fqdn_sender,
 reject_non_fqdn_recipient,

1. Store api keys in a xml file

Put xml file "api_keys.xml" in the directory "res/value/".

api_keys.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="THE_MOVIE_DB_API_TOKEN">XXXXX</string>
</resources>
@carlhoerberg
carlhoerberg / reconnect.js
Created May 13, 2015 14:45
How to build reconnect logic for amqplib
var amqp = require('amqplib/callback_api');
// if the connection is closed or fails to be established at all, we will reconnect
var amqpConn = null;
function start() {
amqp.connect(process.env.CLOUDAMQP_URL + "?heartbeat=60", function(err, conn) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(start, 1000);
}
@ghinda
ghinda / object-to-form-data.js
Last active March 30, 2024 18:51
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {
package com.mma.fingerprint;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.EnumMap;
import java.util.concurrent.LinkedBlockingQueue;
@dmdavis
dmdavis / utc_to_local.py
Created March 20, 2014 18:31
Example of converting UTC to local time using python-dateutil
#!/usr/bin/env python
# encoding: utf-8
"""
utc_to_local.py
Example of converting UTC to local time using python-dateutil.
https://pypi.python.org/pypi/python-dateutil
"""
from datetime import datetime
@mrob11
mrob11 / models.py
Last active October 27, 2020 11:22
Simple follower/following relationship in Django
$ ./manage.py shell
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from followers.models import *
>>> john = User.objects.create_user('john', 'lennon@thebeatles.com', 'password')
>>> paul = User.objects.create_user('paul', 'mccartney@thebeatles.com', 'password')
>>> george = User.objects.create_user('george', 'harrison@thebeatles.com', 'password')
>>> ringo = User.objects.create_user('ringo', 'starr@thebeatles.com', 'password')