Skip to content

Instantly share code, notes, and snippets.

@sarkistlt
sarkistlt / is-anagram.js
Last active March 31, 2016 21:19
String comparison to the number of matching symbols.
let isAnagram = (str1, str2) => {
if (str1.length !== str2.length) return console.log('false');
let obj1 = {},
obj2 = {},
equal = str1.length;
for (let i = 0; i < str1.length; i++) {
(obj1[str1.charAt(i)]) ? obj1[str1.charAt(i)] += 1 : obj1[str1.charAt(i)] = 1;
(obj2[str2.charAt(i)]) ? obj2[str2.charAt(i)] += 1 : obj2[str2.charAt(i)] = 1;
@sarkistlt
sarkistlt / Sample.html
Created April 1, 2016 20:57
DIRECTV_test-task
<!doctype html>
<html>
<head>
<script src="sample.js"></script>
<link rel="stylesheet" href="sample.css">
</head>
<body>
<div id="mainDiv">
<div id="innerDiv" style="padding: 10px">
<div class="leftDiv">
@sarkistlt
sarkistlt / Sample.css
Created April 1, 2016 20:59
DIRECTV_test-task
#mainDiv {
height: 100vh;
width: 100vw;
border: 1px solid red;
}
#innerDiv {
height: 100vh;
width: 100vw;
border: 1px solid green;
@sarkistlt
sarkistlt / Sample.js
Created April 1, 2016 21:01
DIRECTV_test-task
"use strict"
window.onload = () => {
let image2Src = null,
elem = document.getElementById('mainDiv'),
getImage1btn = document.createElement('button'),
getImage2btn = document.createElement('button');
getImage1btn.innerHTML = 'getImage1Data';
getImage2btn.innerHTML = 'getImage2Data';
@sarkistlt
sarkistlt / module-example.jsx
Last active May 3, 2016 06:47
Used technologies: MeteorJs, ReactJs, NodeJs, Bootstrap, react-Bootstrap. How you can see, the whole Web application created with separate modules. Each modules include his own dependencies and can easily be used in other projects. I don't use RequireJs, because I work with MeteorJs which allow me to work with NodeJs using ES6 syntaxes.
/* Import variables ***************************************************************************************************/
import React from 'react';
import ReactDOM from 'react-dom';
import {composeWithTracker} from 'react-komposer';
import {Modal, Button} from 'react-bootstrap';
import './deposit.css';
/* React components ***************************************************************************************************/
const Deposit = (props) => {
@sarkistlt
sarkistlt / synacor_weather.js
Created May 7, 2016 21:57
native javaScript ES6. just insert this file in any HTML and js will do rest of work.
let XHR = (`onload` in new XMLHttpRequest()) ? XMLHttpRequest : XDomainRequest; //to support IE8
let ipXhr = new XHR(),
weatherXhr = new XHR();
let creatElement = function () {
let layoutBody = document.createElement('div'),
h1 = document.createElement('h1'),
p = document.createElement('p'),
img = document.createElement('img'),
h2 = document.createElement('h2');
@sarkistlt
sarkistlt / weather.jsx
Last active May 10, 2016 17:40
React component with weather-widget
/* Import variables ***************************************************************************************************/
import React from 'react';
import ReactDOM from 'react-dom';
/* React components ***************************************************************************************************/
export default class Weather extends React.Component{
constructor(props) {
super(props);
this.state = {
city: ``,
/**
* MONGOSE SCHEMA
* [questions-schema.js]
*/
import mongoose from 'mongoose';
const selectSchema = {
value: String,
label: String
};
function ignoreThisMessage(isUncaught, args, payload) {
var ignore = "Protocols, domains, and ports must match.";
if (
payload &&
payload.body &&
payload.body.message &&
payload.body.message.body &&
!!~payload.body.message.body.indexOf(ignore)
) {
return true
import {
GraphQLBoolean,
GraphQLEnumType,
GraphQLFloat,
GraphQLInputObjectType,
GraphQLInt,
GraphQLInterfaceType,
GraphQLList,
GraphQLObjectType,
GraphQLString,