Skip to content

Instantly share code, notes, and snippets.

View amalagaura's full-sized avatar

Ankur Sethi amalagaura

View GitHub Profile
---
id: 1
type: book
awards:
books:
- id: 1
title: International Botev
reviewers:
- id: 2
name: PersonB
@amalagaura
amalagaura / runme.sh
Created December 15, 2011 04:29
Commands to fix damn CRLF with rubymine saving in windows
# Remove everything from the index
git rm --cached -r .
# Re-add all the deleted files to the index
# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>."
git diff --cached --name-only -z | xargs -0 git add
# Commit
git commit -m "Fix CRLF"
@amalagaura
amalagaura / rubyDotNetHash.rb
Created May 9, 2016 16:57
.NET passwords operable in ruby
ruby dotNetHash.rb password123 LU7hUk4MXAvlq6DksvP9SQ==
require "base64"
require “digest”
# Encode password as double-width characters
password_as_text = ARGV.first
double_width_password = []
double_width_password = password_as_text.encode("UTF-16LE").bytes.to_a
# Unencode the salt
"jruby-rack-worker#1" daemon prio=10 tid=0x00007f4a8ce3d000 nid=0x3c08 runnable [0x00007f4a4f042000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.NativeThread.current(Native Method)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:325)
- locked <0x000000075a084f68> (a java.lang.Object)
- locked <0x000000075a084f48> (a java.lang.Object)
at org.jruby.ext.openssl.SSLSocket.readAndUnwrap(SSLSocket.java:513)
at org.jruby.ext.openssl.SSLSocket.read(SSLSocket.java:501)
at org.jruby.ext.openssl.SSLSocket.do_sysread(SSLSocket.java:613)
at org.jruby.ext.openssl.SSLSocket.sysread_nonblock(SSLSocket.java:636)
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Rails 4.2 throws an exception on last test case
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
Your system is raring to brew.
@amalagaura
amalagaura / brew doctor
Created February 1, 2013 20:10
There is no makefile output in ~/Library/Logs/Homebrew/v8
brew doctor
Your system is raring to brew.
@amalagaura
amalagaura / edit.html.slim
Created April 16, 2012 16:45
complicated slim template
- content_for :sidebar do
= render_widget :contract_summary, :display, @contract, true
- content_for :extra_header_row do
- unless @hide_edit_link
.price-offset.breadcrumb
span = "Go to "
= link_to *@link_to
- content_for :content do
- Contract.filtered_categories.each do |category|
- config_set = @category_details[category.name][:config_set]
@amalagaura
amalagaura / ability.rb
Created December 13, 2011 20:23 — forked from watson/ability.rb
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all