Skip to content

Instantly share code, notes, and snippets.

View israeljrs's full-sized avatar

Israel Junior israeljrs

View GitHub Profile
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
# encoding: utf-8
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
@israeljrs
israeljrs / rails_github_heroku.md
Created March 5, 2015 16:52
Roteiro para iniciar aplicação

This is a list of steps to:

  • Setup a new Rails app
  • Initialize a local repository using git
  • Create a new remote repository using GitHub
  • Change README.rdoc
  • Deploy to a cloud service - Heroku

Assumptions:

  • Ruby is installed (v 1.9.3)
  • Rails is installed (v 3.2.3)
@israeljrs
israeljrs / sample.js
Created May 12, 2015 12:56
JavaScript add a Even ,odd class in your listing
<ul id="list">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
<script>
@israeljrs
israeljrs / sample_ffmpeg.c
Created March 14, 2016 13:05
ffmpeg api snippet codes.
/*
You don't need a file, just use your internet-audiostream url to open. like this:
*/
AVFormatContext *ic = avformat_alloc_context();
err = avformat_open_input(&ic, "rtmp://www.something.com/a.mp4", NULL, NULL);
//Fade an element out and then remove it
var s = document.getElementById('thing').style;
s.opacity = 1;
(function fade(){(s.opacity-=.1)<0?s.display="none":setTimeout(fade,40)})();
//Make an AJAX call
var r = new XMLHttpRequest();
r.open("POST", "path/to/api", true);
r.onreadystatechange = function () {
if (r.readyState != 4 || r.status != 200) return;

Stream by node.js

Streams are one of the most used concepts in nodejs, but also one that most people find hard to fully grasp. So with this note I aim to shed some light on their purpose and how you can you can use them in your projects. Here I'm not going to go into too much detail on the various types of streams, but rather a simple overview what they are and the way to use them.

What are streams in node.js ?

The official definition of a stream in nodejs is as follows:

A stream is an abstract interface implemented by various objects in Node.js. Streams are readable, writable, or both. All streams are instances

@israeljrs
israeljrs / precompile.md
Created August 15, 2016 01:18 — forked from mrbongiolo/precompile.md
HOW TO: Rails 4.2 add 'vendor/asset' to precompile list

To enable the precompilation of all non.js/.css assets within vendor/assets just add this to config/initializers/assets.rb:

Rails.application.config.assets.precompile << Proc.new { |path, fn| fn =~ /vendor\/assets/ && !%w(.js .css).include?(File.extname(path)) }

Be aware that this will precompile ALL non .js/.css assets that you have there, some plugins or libraries might have .txt or other files around, and those would end up into your precompiled list also.

If you need to precompile images only, you could use this:

Rails.application.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
@israeljrs
israeljrs / README.md
Created September 28, 2016 19:22
Show command to update pip in python.

list packages outdated.

$ pip list --outdated

update one package.

$ pip install -U package

update all packages with answoer yes/no.

@israeljrs
israeljrs / socket.c
Last active October 6, 2016 19:37 — forked from nolim1t/socket.c
HTTP Request in C using low level write to socket functionality
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>