Skip to content

Instantly share code, notes, and snippets.

View oleksiilevzhynskyi's full-sized avatar

Oleksii Levzhynskyi oleksiilevzhynskyi

View GitHub Profile
@oleksiilevzhynskyi
oleksiilevzhynskyi / Quiz
Last active December 17, 2021 16:21
Quiz: all topics
### Quiz:
1. What is result of next line of code?
typeof null
Answer:
* `null`
* `object`
* `undefined`
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests

#Quiz:

  1. What’s the result of:

     function A() {}
     A.prototype.name = 'A';
    
     var a = new A();
     var b = new A();
    

#Quiz:

  1. What’s the result of:

     console.log(f());
     function f() {
         return 1;
     }
    

Answers:

Answer this questions to check you general understanding of the topic:

Quiz:

  1. How do you write a conditional statement for executing some code if i is equal to 5?

    • if (i==5)
    • if i=5
    • if i=5 then
    • if i==5 then
  2. What is an array?

@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:4240492
Created December 8, 2012 14:40
"restart" network on OS X
sudo ifconfig en0 down; sleep 1; sudo ifconfig en0 up
Write a program, which outputs numbers from 0 to 1000 without:
loops (do, while, for, etc.)
jumps (goto)
exceptions
conditions
boolean operators (and, or, etc.)
comparison operators (<, >, etc.)
ranges
preprocessor shit
@oleksiilevzhynskyi
oleksiilevzhynskyi / gist:3524163
Created August 30, 2012 08:27
Brew "Error: Cannot write to /usr/local/Cellar"
sudo chown -R $USER /usr/local
sudo chown -RL mysql:mysql /usr/local/mysql/data
{
"args":
{
"cycle": "previous"
},
"auto_complete": false,
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"command": "alternative_autocomplete",
"context":
[
@oleksiilevzhynskyi
oleksiilevzhynskyi / array
Created June 18, 2012 17:26
the sum of two
t1 = Time.now
file = File.new(ARGV[0] || "input.txt", "r")
numbers = file.readlines.map!(&:to_i)
p Time.now - t1
[231552, 234756, 596873, 648219, 726312, 981237, 988331,1277361,1283379].each do |x|
tmp = Array.new(numbers.size)
time = Time.now
res = numbers.detect { |el| tmp[el] || ((x - el) > 0 && (tmp[x - el] = true) && false) } ? 'yes' : 'no '
p "#{'%7.0f' % x} - #{res} - #{Time.now - time}"