Skip to content

Instantly share code, notes, and snippets.

View samuelralak's full-sized avatar

Samuel Ralak samuelralak

View GitHub Profile
@samuelralak
samuelralak / solution.ex
Last active March 25, 2023 20:29
HackerRank 30 days of code. Day 0: Hello, World. Read from STDIN in Elixir
defmodule Solution do
#Enter your code here. Read input from STDIN. Print output to STDOUT
def read do
case IO.read(:stdio, :line) do
:eof -> :ok
{:error, reason} -> IO.puts "Error: #{reason}"
data ->
IO.write(:stdio, "Hello, World. \n")
IO.write(:stdio, data)
read()
Run this command to install MG-CLI:
sudo apt-get update && wget https://minergate.com/download/deb-cli -O minergate-cli.deb && sudo dpkg -i minergate-cli.deb
to start miner (4 cores for BCN) use this command:
minergate-cli -user <YOUR@EMAIL.KAPPA> -bcn 4
Feel free to send some of your earnings to me:
BTC (Don't attempt to send other coins to this address!): 17f77AYHsQbdsB1Q6BbqPahJ8ZrjFLYH2j
@samuelralak
samuelralak / inputTypeNumberPolyfill.js
Created August 10, 2016 13:37 — forked from nbouvrette/inputTypeNumberPolyfill.js
Stand alone JavaScript polyfill allow only numbers on input of type number.
/**
* Stand alone polyfill allow only numbers on input of type number.
*
* While input filtering is already supported by default by some browsers, maximum length has not been implemented by
* any. This script will solve both issue and make sure that only digits can be entered in input elements of type
* number. If the optional attribute `max` is set, it will calculate it's length and mimic the `maxlength` behavior on
* input of type text.
*
* Supports:
*
@samuelralak
samuelralak / post_xml.rb
Created July 9, 2016 21:42 — forked from mattriley/post_xml.rb
Ruby HTTP POST request containing XML content
require 'net/http'
def post_xml url_string, xml_string
uri = URI.parse url_string
request = Net::HTTP::Post.new uri.path
request.body = xml_string
request.content_type = 'text/xml'
response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
response.body
end
@samuelralak
samuelralak / post.rb
Created April 15, 2016 13:34 — forked from kizzx2/post.rb
A clean and elegant approach to partial object validation with Rails + Wicked wizards (using session to store the partial object)
class Post < ActiveRecord::Base
attr_accessible :body, :price, :title
validates_presence_of :title
validates_length_of :title, minimum: 10
validates_presence_of :body
validates_numericality_of :price, greater_than: 0
end
module AmazonSignature
extend self
def signature
Base64.encode64(
OpenSSL::HMAC.digest(
OpenSSL::Digest.new('sha1'),
AWS_CONFIG['secret_access_key'], self.policy
)
).gsub("\n", "")
@samuelralak
samuelralak / localhost.conf
Last active September 8, 2015 20:46 — forked from jtadeulopes/localhost.conf
Default nginx server
upstream project {
server unix:///home/deploy/apps/avtomat_kalashnikova/shared/tmp/sockets/avtomat_kalashnikova-puma.sock;
}
server {
listen 80;
server_name localhost;
root /home/deploy/apps/avtomat_kalashnikova/current/public;
upstream puma {
server unix:///home/deploy/apps/avtomat_kalashnikova/shared/tmp/sockets/avtomat_kalashnikova-puma.sock;
}
server {
listen 80 default_server deferred;
# server_name example.com;
root /home/deploy/apps/avtomat_kalashnikova/current/public;
access_log /home/deploy/apps/avtomat_kalashnikova/current/log/nginx.access.log;
@samuelralak
samuelralak / gvm_installation
Created August 7, 2015 10:29
installing go using gvm
1. Clone the Repo and Add to User Directory
1
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
This command uses cURL to grab the GitHub repo and install it into your user directory. The file that this repo is placed in is ~/.gvm.
2. Open Your ~/.bashrc and Source the GVM Directory
1
<!DOCTYPE html>
<html>
<head>
<title>My Rails App</title>
<%- if protect_against_forgery? -%>
<meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" />
<%- end -%>
<%= javascript_include_tag 'jquery', 'rails' %>
</head>
<body>