Skip to content

Instantly share code, notes, and snippets.

View ryush00's full-sized avatar

SeongHoon Ryu ryush00

  • South Korea
  • 10:28 (UTC +09:00)
View GitHub Profile
@ryush00
ryush00 / install-rbenv-amazon-linux-ami.sh
Last active July 13, 2022 06:49 — forked from luisbebop/install-rbenv-amazon-linux-ami.sh
Install rbenv on Amazon Linux AMI
sudo yum install -y git gcc make readline-devel openssl-devel
git clone https://github.com/rbenv/rbenv ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
# Install ruby-build system-widely
git clone https://github.com/rbenv/ruby-build /tmp/ruby-build
cd /tmp/ruby-build
@ryush00
ryush00 / gist:f580229e070555b154fb
Created February 23, 2016 17:21 — forked from wedtm/gist:1906478
Ruby based Minecraft Vanilla Query Check
#
# Tested on 1.9.2-p290, Written by Miles Smith (WedTM)
#
require 'socket'
class MCQuery
MAGIC_PREFIX = "\xFE\xFD"
PACKET_TYPE_CHALLENGE = "\x09"
PACKET_TYPE_QUERY = "\x00"
@ryush00
ryush00 / friendly_urls.markdown
Last active August 29, 2015 14:26 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

require 'socket'
##
# Pings a minecraft server and returns motd and playercount.
# Works with ruby >=1.9.3/2.0.0
#
# More information and sample code here:
# http://wiki.vg/Server_List_Ping
##
class MinecraftPing
# This class is needed since Mongoid doesn't support Multi-parameter
# attributes in version 4.0 before it's moved to active model in rails 4
#
# https://github.com/mongoid/mongoid/issues/2954
#
require "spec_helper"
describe Mongoid::MultiParameterAttributes do
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
@ryush00
ryush00 / Skin.php
Last active August 29, 2015 14:14 — forked from tonybruess/Skin.php
<?php
class Skin {
public static function get($username) {
$steve = in_array(strtolower($username), array("steve", "player", "default"));
if(!$steve) $contents = self::fetch('http://skins.minecraft.net/MinecraftSkins/' . $username . '.png');
$defaultImage = WideImage::load("char.png");
$defaultType = "image/png";
if ($steve || $contents === false) {
$img = $defaultImage;