Skip to content

Instantly share code, notes, and snippets.

View sashaProdan's full-sized avatar

sashaProdan sashaProdan

  • San-Francisco, CA
View GitHub Profile
version: '3.8'
services:
redis:
image: "redis:3.2"
expose:
- "6379"
server:
build:
context: ./
dockerfile: Dockerfile.server
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "The AWS CloudFormation template for this Serverless application",
"Resources": {
"ServerlessDeploymentBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
"ServerSideEncryptionConfiguration": [
{
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "The AWS CloudFormation template for this Serverless application",
"Resources": {
"ServerlessDeploymentBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketEncryption": {
"ServerSideEncryptionConfiguration": [
{

Let's say we have a generic class Animal with some behavior. We also have classes Fish and Bird that inherit from class Animal

class Animal
  def move
    "I can move!"
  end
end

class Fish < Animal; end
  1. In the code below do..end defines a block. The loop here is an example of a method invocation with a block. According to variable scoping rules for this code structure, variables defined within the block are not accessible outside of the block. But variables defined in outer scope can be referenced within the block.

    Variable color is accessible within the block passed to loop method. Hence it was reassined a new object and line 9 outputs the new value of variable color. Variable shape was defined within block and inaccessible outside of the block. There is no variable shape defined in the main scope, therefore line 10 throws an error.

  2. Here we have three scope levels. The main scope, the scope within the block passed to times method and the scope within the block passed to loop method. According to variable scoping rules for method invocations with a block mentioned in the previous question, color is accessible within times block, shape is accessible within loop block b

Clicking on "Add new to do" shows the modal.

Displays the current selected "todo group" with the corresponding count of todos.

Hovering on a todo item highlights the todo.

Clicking on the area surrounding the todo name toggles the todo state (complete/not complete).

The todo name displayed on the todo list is of the following form - "{title} - {month}/{year}" (i.e Item 1 - 02/15). Hovering over the todo name highlights the text.

require 'sinatra/base'
require 'sinatra/contrib'
require 'docdsl'
require 'sinatra/activerecord'
require_relative 'lib/contacts'
class ContactsApp < Sinatra::Base
register Sinatra::Contrib
register Sinatra::DocDsl
@sashaProdan
sashaProdan / calculator.html
Created February 14, 2018 21:16
Calculator (JavaScript)
<!doctype html>
<html lang="en-US">
<head>
<title>Calculator</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<p id="result">Enter two numbers below and choose an operation:</p>
/* Todo object */
function Todo(data) {
this.title = data.title;
this.month = data.month;
this.year = data.year;
this.description = data.description;
this.completed = false;
this.isWithinMonthYear = function(month, year) {
return this.month === String(month) &&

Write a program that can calculate the Hamming difference between two DNA strands.

A mutation is simply a mistake that occurs during the creation or copying of a nucleic acid, in particular DNA. Because nucleic acids are vital to cellular functions, mutations tend to cause a ripple effect throughout the cell. Although mutations are technically mistakes, a very rare mutation may equip the cell with a beneficial attribute. In fact, the macro effects of evolution are attributable by the accumulated result of beneficial microscopic mutations over many generations.

The simplest and most common type of nucleic acid mutation is a point mutation, which replaces one base with another at a single nucleotide.

By counting the number of differences between two homologous DNA strands taken from different genomes with a common ancestor, we get a measure of the minimum number of point mutations that could have occurred on the evolutionary path between the two strands.

This is called the 'Hamming distance