Skip to content

Instantly share code, notes, and snippets.

View irfanfadilah's full-sized avatar
:octocat:
Coding For Fun

Irfan Fadilah irfanfadilah

:octocat:
Coding For Fun
View GitHub Profile
@irfanfadilah
irfanfadilah / Ubuntu Alias Command
Last active January 14, 2018 08:32
Create Alias Command in Ubuntu
1. Create a file called .bash_aliases using your favorite text editor.
gedit .bash_aliases
2. Write the alias you want to create, e.g:
alias update='sudo apt-get update'
3. Save the file and reconfigure your bashrc.
. ~/.bashrc
4. Check if your alias is added correctly.
@irfanfadilah
irfanfadilah / hubot_brain_sample.coffee
Created November 30, 2015 08:03
[Sample Code] Hubot Brains Storage (Slack Adapter)
robot.respond /accumulate this request to my account/i, (msg) ->
user_id = msg.message.user.id; user_name = msg.message.user.name
requests = robot.brain.get(user_id)
if requests == null
robot.brain.set(user_id, 1)
else
robot.brain.set(user_id, requests+1)
requests = robot.brain.get(user_id)
content = if requests > 5
# User exceed limit
@irfanfadilah
irfanfadilah / youtube_api_live_event.rb
Created January 21, 2016 04:48
YouTube API Snippet for Live Event (Broadcast and Stream)
# Get Access Token
refresh_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
access_token = JSON.parse(
RestClient.post("https://accounts.google.com/o/oauth2/token", {
client_id: Rails.application.secrets.google_client_id,
client_secret: Rails.application.secrets.google_client_secret,
refresh_token: refresh_token, grant_type: "refresh_token"
})
@irfanfadilah
irfanfadilah / wowza_api_stream_target.rb
Created January 21, 2016 09:49
Wowza API Snipped for Stream Target
wowza_stream_name = "wowza-stream-name"
youtube_host = "x.rtmp.youtube.com"
youtube_application = "livex"
youtube_stream_name = "xxxxx.xxxx-xxxx-xxxx-xxxx"
stream_target = "curl --digest -u \"wowza:#{stream_server.instance_id}\" -X POST --header \"Accept:application/json; charset=utf-8\" --header \"Content-type:application/json; charset=utf-8\" \"#{wowza_host}/pushpublish/mapentries/youtube\" -d '{
\"restURI\": \"#{wowza_host}/pushpublish/mapentries/youtube\",
\"serverName\":\"_defaultServer_\",
\"sourceStreamName\": \"#{wowza_stream_name}\",
\"entryName\": \"youtube\",
@irfanfadilah
irfanfadilah / dailymotion_api_live_event.rb
Created January 26, 2016 07:30
DailyMotion API Snippet for Live Event (Broadcast and Stream)
client_id = "xxxxxxxxxxxxxxxxxxxx"
client_secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
redirect_uri = "http://localhost:3000/callback/dailymotion"
# Ask user permission
get = "https://www.dailymotion.com/oauth/authorize?response_type=code&client_id=#{client_id}&redirect_uri=#{redirect_uri}&scope=manage_videos"
# Get access_token & refresh_token
@irfanfadilah
irfanfadilah / dnsmasq.txt
Last active October 9, 2018 11:58
Rails Subdomain Development with DNSMasq
Ubuntu:
sudo apt-get install dnsmasq
sudo gedit /etc/dnsmasq.conf
add: address=/rails.env/127.0.0.1
sudo service dnsmasq restart
Mac:
brew install dnsmasq
@irfanfadilah
irfanfadilah / Preferences.sublime-settings
Last active November 17, 2020 03:21
Sublime Text 3 - Preferences
{
"color_scheme": "Packages/Material Theme/schemes/Material-Theme-Darker.tmTheme",
"default_line_ending": "unix",
"drag_text": false,
"ensure_newline_at_eof_on_save": true,
"font_size": 10,
"ignored_packages": ["Vintage"],
"line_padding_bottom": 1.5,
"line_padding_top": 1.5,
"material_theme_accent_scrollbars": true,
@irfanfadilah
irfanfadilah / simple-image-upload.js
Created January 23, 2017 04:58
Simple Validation and Preview for Image Upload (JavaScript)
var _URL = window.URL || window.webkitURL;
$("#article_image").change(function(){
var file, img, reader;
if ((file = this.files[0])) {
img = new Image();
img.onload = function(){
if ( (this.width < 960) || (this.height < 300) ) {
alert("Image must be larger than 960x300 pixels!")
} else {
@irfanfadilah
irfanfadilah / .hyper.js
Last active December 14, 2022 07:36
Hyper Terminal - Preferences
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@irfanfadilah
irfanfadilah / settings.json
Last active February 18, 2020 02:11
Visual Studio Code - Preferences
{
"editor.tabSize": 2,
"editor.smoothScrolling": true,
"editor.minimap.enabled": false,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"workbench.startupEditor": "none",
"editor.copyWithSyntaxHighlighting": false,
"editor.matchBrackets": "never",