Skip to content

Instantly share code, notes, and snippets.

View denpatin's full-sized avatar
🐷
己亥

Den Patin 丁丹旭 denpatin

🐷
己亥
View GitHub Profile
@denpatin
denpatin / 32.asm
Created September 25, 2015 09:59 — forked from FiloSottile/32.asm
NASM Hello World for x86 and x86_64 Intel Mac OS X (get yourself an updated nasm with brew)
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
global start
section .text
start:
push dword msg.len
push dword msg
push dword 1
mov eax, 4
@denpatin
denpatin / rubyup.md
Created October 1, 2015 16:28
Ruby hacks

Smart hacks for Ruby

Interpolate arrays

pets = %w[dog cat rabbit]
puts "My first pet is a %s, my second one a %s and my third is a %s" % pets
@denpatin
denpatin / commands.md
Last active December 23, 2015 11:23
Commands for test
Команда Описание
apropos ищет в названиях и описаниях страниц мануала
at выполняет команды в заданное время
atq выдаёт список заданий пользователя (если он суперпользователь — все задания)
atrm удаляет задания по их номеру
batch выполняет команды, если уровни загрузки системы это позволяют
bg переводит выполнение команды в фоновый режим
cal отображает календарь
cat объединяет файлы и выводит их на стандартный поток вывода
@denpatin
denpatin / springer.sh
Last active January 19, 2016 03:58
Script for downloading free books from Springer
#!/bin/bash
#
# Usage:
# $ springer.sh
# will save all books
#
# $ springer.sh word
# will save all books whose titles or authors match "word"
# Link with books and links
@denpatin
denpatin / pogoda.rb
Created January 5, 2016 15:07
Getting current weather from Yandex.Pogoda into Terminal
#!/usr/bin/ruby
require 'net/http'
require 'uri'
require 'rexml/document'
require 'date'
# TODO: Make city selectable, not hardcoded
def city
26063 # St Petersburg
@denpatin
denpatin / make.sh
Created January 21, 2016 09:04 — forked from artzub/make.sh
Install JetBrains Hub + YouTrack + UpSource + Nginx
#!/bin/bash
apt-get install mc htop git unzip wget curl -y
echo
echo "====================================================="
echo " WELCOME"
echo "====================================================="
echo
echo "Hub"
@denpatin
denpatin / genre-definition.tex
Last active January 30, 2016 19:07
Simplified genre-definition formula from master thesis
A = \| a_{ij} \|, i = 1, \dotsc, j = 1, \dotsc, 4,
A_i = ( a_{i1}, a_{i2}, a_{i3}, a_{i4} ),
M_k = \{ m_{ik} = | a_{ik} - a_{i1} | : m_{ik} = \min_{j=2, \dotsc, 4}( |a_{ij} - a_{i1}| ), i = 1, \ldots\},
P_k = \frac{ card(M_k) }{ \sum\limits_{k=2}^{4} card(M_k) }
@denpatin
denpatin / progressbar.rb
Created March 6, 2016 10:40
Showing progress bar for each-ish methods
=begin
Usage examples:
big_array.each_with_progress(){ |e| ... }
(0...1000000).each_with_progress(){ |i| ... }
big_hash.each_key_with_progress(){ |k| ... }
@denpatin
denpatin / pyramid.rb
Created March 13, 2016 17:02
Ruby implementation of a pyramid with a custom height
#
# Input: Pyramid's height
# Output: Pyramid with given height and width = height * 2 - 1
#
MAX_HEIGHT = 20
prompt = 'Enter pyramid\'s height: '
puts prompt
while height = gets.chomp
li $t0, 0x10010000
addiu $t1, $t0, 0x100
li $t2, 0
li $t3, 1
Square:
sw $t2, ($t0)
addiu $t0, $t0, 4
add $t2, $t2, $t3
addiu $t3, $t3, 2
bne $t0, $t1, Square