Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am hunj on github.
  • I am hunj (https://keybase.io/hunj) on keybase.
  • I have a public key ASAJoF7vcKllXYF7TfPzomysgiHFM0Q53xtHso0p8TAv0wo

To claim this, I am signing this object:

@hunj
hunj / README.md
Created April 29, 2020 22:40 — forked from kordless/README.md
Rust Server Deployment for Google Container Engine

Howdy Y'all! I'm @kordless on YouTube and I occasionally play and stream Rust, the game.

This repo is for deploying a Rust Server running on Google Container Engine. Google has a deal going where you can get $300 of free credits for a year on Google Cloud, so it's a good excuse to signup and run your own server. And no, I don't work for Google!

This deployment uses an image built by @dids, which is hosted on Docker Hub: https://hub.docker.com/r/didstopia/rust-server/

This deployment method can be used to start a small server to play with friends or practice building things. In a few days, I'll update the scripts to include a way to save the content you've created, in-game, with others who can then run their own servers and load your content in to explore it for themselves.

For now, start by navigating to Google Cloud and signup for an account. You'll need to enter some credit card details to get this going, but Google is giving you $300 in credits for the next year. Should be e

@hunj
hunj / params.py
Created July 11, 2018 15:46
[Python] Inspect params inside a function
import inspect
frame = inspect.currentframe()
args, _, _, values = inspect.getargvalues(frame)
print('function name "%s"' % inspect.getframeinfo(frame)[2])
for i in args:
print(" %s = %s" % (i, values[i]))
@hunj
hunj / gist:8549840acc266c1e19761959bd028300
Created December 1, 2016 15:06
result of running `python pi_monte-carlo.py 1`
Calculated pi: 3.1411426428303537942242780347543442930366295786973371671458932366545818227278409801225153144143017877234654331791473934241780222527815976997124640580072509063632954119264908113514189273659207400925115639454931866483310413801725215651956494561820227528441055131891486435804475559444930616327040880110013751718964870608826103262907863482935366920865108138517314664333041630203775471933991748968621077634704338042255281910238779847480935116889611201400175021877734716839604950618827353419177397174646830853856732091511438929866233279159894986873359169896237029628703587948493561695211901487685960745093136642080260032504063007875984498062257782222777847230903862982872859107388423552944118014751843980497562195274409301162645330666333291661457682210276284535566945868233529191148893611701462682835354419302412801600200025003125390673834229278659832479059882485310663832979122390298787348418552319039879984998124765595699462432804100512564070508813601700212526565820727590948868608576072009001125140642580322540
@hunj
hunj / compute_pi.py
Created November 8, 2016 21:31
Compute π using Nilakantha's series
from decimal import *
def compute_pi():
pi = Decimal(3.0)
curr_multiplier = Decimal(2)
iteration = Decimal(0)
load = Decimal(1)
getcontext().prec = 6
while 1:
@hunj
hunj / euler_003.rb
Last active June 15, 2016 04:17
Project Euler #003 solution, comparing with square root
require 'benchmark'
the_number = 600_851_475_143
# monkeypatching
class Fixnum
def prime? # O(n)
(2..(self - 1)).each do |divisor|
return false if self % divisor == 0
end
@hunj
hunj / gen.rb
Created March 6, 2016 13:39
Generate random numbers
require 'csv'
# Data generation
@data = {}
(0..100).each do |i|
@data[i] = {
:age => Random.rand(18...80),
:gender => Random.rand(0..1),
:prescription_history => []
@hunj
hunj / perfect_number.rb
Created February 7, 2016 20:04
perfect number!
def perfect_number? number
return number == divisors_of(number)
end
def divisors_of number
arr = []
(1..number).each do |iter|
if number % iter == 0
arr << iter
end
@hunj
hunj / dummy_generate.rb
Created September 24, 2015 01:12
Generates a dummy file full of 0's and 1's up to desired size
DESIRED_SIZE = 1073741824 # 1gb
FILE_NAME = "dummy" # name of the dummy file
dummy_file = File.new(FILE_NAME, "w")
while dummy_file.size < DESIRED_SIZE
dummy_file.write([0,1].sample)
end
dummy_file.close
@hunj
hunj / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.