Skip to content

Instantly share code, notes, and snippets.

Avatar
🧑‍💻
Doing some useful stuff

Nikita Levchuk nlevchuk

🧑‍💻
Doing some useful stuff
  • Tomsk, Russia
View GitHub Profile
@gaearon
gaearon / modern_js.md
Last active Dec 2, 2021
Modern JavaScript in React Documentation
View modern_js.md

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@sharipov-ru
sharipov-ru / exceptions_handling.rb
Last active Aug 29, 2015
Exceptions handling with ruby 2.1
View exceptions_handling.rb
class ServiceException < StandardError; end
class RepositoryException < StandardError; end
class RethinkDBError < StandardError; end
class RecordsController
def self.update
RecordsService.update(@record)
rescue ServiceException => error
puts "Failure: #{error.inspect}"
puts "Original failure: #{error.cause.inspect}"
@niquola
niquola / list.md
Last active May 20, 2018
Must Read from Ravil Bayramgalin (https://github.com/brainopia) + my small adds :)
View list.md

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)

@the-teacher
the-teacher / spec_helper.rb
Created Dec 10, 2013
Rspec + Views + Isolated Engine
View spec_helper.rb
ActionView::TestCase::TestController.instance_eval do
helper MyEngine.routes.url_helpers
helper ApplicationHelper
include Devise::TestHelpers
end
@nicolashery
nicolashery / environment-variables-jekyll-templates.md
Last active Oct 1, 2021
Make environment variables available in Jekyll Liquid templates
View environment-variables-jekyll-templates.md

Environment variables in Jekyll templates

This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml file (which is likely to be committed in your GitHub repository).

Copy the environment_variables.rb plugin to your _plugins folder, and add any environment variable you wish to have available on the site.config object.

In a Liquid template, that information will be available through the site object. For example, _layouts/default.html could contain:

<head>
@jhilden
jhilden / tabs.js.coffee
Created Aug 28, 2012
Remove jquery-ui styling for tabs
View tabs.js.coffee
$ ->
jquery_ui_classes = [".ui-tabs", ".ui-tabs-nav", ".ui-tabs-panel", ".ui-widget", ".ui-widget-header", ".ui-widget-content", ".ui-corner-all", ".ui-corner-top", ".ui-corner-bottom", ".ui-helper-clearfix", ".ui-helper-reset", ".ui-state-default"]
$(".js-tabs").tabs().each ->
# removes all the jquery-ui specific classes (except ones like ui-state-active)
$elements = $(this).find( jquery_ui_classes.join(", ") ).andSelf()
$elements.removeClass( jquery_ui_classes.join(" ").replace(/\./g, "") )
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created Jul 25, 2012
Convert seconds into HH:MM:SS in Ruby
View convert-seconds-into-hh-mm-ss-in-ruby.rb
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time
View ruby.2.0.0-setup.sh
#!/usr/bin/env bash
# repository
cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
# system update
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
@larsar
larsar / shared_folder_centos_virtualbox.txt
Created Jan 27, 2012
Mount shared folder on CentOS in VirtualBox
View shared_folder_centos_virtualbox.txt
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
@sinisterchipmunk
sinisterchipmunk / LICENSE
Last active Dec 3, 2021
tar, gzip, and untar files using ruby in memory without tempfiles
View LICENSE
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in