Skip to content

Instantly share code, notes, and snippets.

STEPS

  • Click on Help menu

  • Select Enter License

  • Then paste given KEY given at bottom

  • Finally click on Use License

@yudapc
yudapc / sum.rb
Created April 9, 2018 00:38 — forked from ProfAvery/sum.rb
15 ways to sum an array in Ruby
#!/usr/bin/env ruby
require 'test/unit'
class TestSums < Test::Unit::TestCase
def setup
@a = [2, 5, 18, 27]
@sum = 0
end
@yudapc
yudapc / chat-frontend.js
Created March 13, 2018 01:05 — forked from martinsik/chat-frontend.js
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@yudapc
yudapc / .command-t
Last active July 30, 2021 09:27
Oh my zsh
if your vim pluggin `command-t` does not work with message:
```
command-t.vim could not load the C extension
```
or with `difference version ruby`
you can try:
```
cd ~/.vim/plugged/command-t/ruby/command-t/ext/command-t
@yudapc
yudapc / gist:4fa9eb551826ea35ea0fab109387b8d3
Created September 18, 2016 09:17 — forked from adamstac/gist:7462202
Install and configure Sendmail on Ubuntu

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

  1. If sendmail isn't installed, install it: sudo apt-get install sendmail
  2. Configure /etc/hosts file: nano /etc/hosts
  3. Make sure the line looks like this: 127.0.0.1 localhost yourhostname
  4. Run Sendmail's config and answer 'Y' to everything: sudo sendmailconfig
  5. Restart apache sudo service apache2 restart
@yudapc
yudapc / A Rails Trick
Last active August 30, 2017 14:45
Rails console
---------------------------
Pengganti .find or .find_by
---------------------------
categories = outlet.categories
categories.select{|c| c[:id] == item[:category_id]}.first
---------------------------
Penganti check value hash
---------------------------
@yudapc
yudapc / Ubuntu 16.04
Last active August 14, 2016 08:04
prepare
sudo apt-get install checkinstall build-essential automake autoconf libtool pkg-config libcurl4-openssl-dev intltool libxml2-dev libgtk2.0-dev libnotify-dev libglib2.0-dev libevent-dev
sudo apt-get install libmagickwand-dev
sudo apt-get install ruby-dev
sudo apt-get install imagemagick
[user]
name = Yuda Cogati
email = [email protected]
[alias]
# checkout a branch
co = "checkout"
# checkout a new branch
cob = "checkout -b"
# adds all changed files
@yudapc
yudapc / Doorkeeper
Last active September 16, 2016 09:56
OAuth2 with rails / ruby
location: `config/initializers/doorkeeper.rb`:
```
resource_owner_authenticator do
current_user || begin
session[:user_return_to] = request.fullpath
redirect_to new_user_session_url
end
end
```
@yudapc
yudapc / Cheat Rspec.rb
Last active October 31, 2016 10:35
RSpec
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)