Skip to content

Instantly share code, notes, and snippets.

View webuniverseio's full-sized avatar

Sergey Zarovskiy webuniverseio

View GitHub Profile
def calc
p "Enter expression (x + y) below. Operations can be any of the following +-/*%. You can use float numbers x.xxx"
x = /^(-?\d+(?:\.\d+)?)\s*?([-+\/*%])\s*?(-?\d+(?:\.\d+)?)$/.match(gets.chomp)
if !x
return p "Please make sure you follow example format"
end
p "Result: #{
skip_trailing_zero(
operation(
get_float(x[1]),
@webuniverseio
webuniverseio / greeting.js
Last active November 1, 2020 20:08
Epic react, example 4 - useEffect: persistent state
const {useState, useEffect} = React;
export default function Greeting() {
const [name, setName] = useStorageState('greeting-name.v4');
const [obj, setObj] = useStorageState('greeting-obj.v1', {date: 1});
setTimeout(() => {
setObj({date: Date.now()})
}, 4000);
//note r is similar to https://github.com/uber/r-dom, but simpler, helps to avoid babel and keeps working on online excersizes
@webuniverseio
webuniverseio / index.js
Created July 2, 2020 01:52
Youtube playlist randomizer
//hint: use as a bookmarklet from playlist page
window.open([...document.querySelectorAll('.playlist-items a.ytd-thumbnail')]
.map(x => x.href)
.map(x => x.split('&')[0])
.map(x => x.split('v=')[1])
.map(x => [Math.random(), x])
.sort(([a], [b]) => a - b)
.map(([_, x]) => x)
.reduce((acc, x, i) => acc + (i === 0 ? '' : ',') + x, 'https://www.youtube.com/embed/?playlist='));

Discussion here https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000014000-Can-t-sign-into-Azure-DB-with-Datagrip-but-can-with-SMSS

Source: https://codejuicer.com/2018/08/29/datagrip-and-azure-sql-server-active-directory-howto/

I Did It! I really like JetBrains products. I use DataGrip all the time in my role as a DBA. I’m in the process of switching our company over the Active Directory logins and wanted to take things for a spin.

Being that most of my work is done on a Mac, DataGrip is pretty much the best tool available for working with a database. This How-To should work on any OS, I just haven’t tested it on any others (yet).

Enough talk: time for action.

version: '3'
services:
nginx-poc:
build: ./nginx
ports:
- "80:8000"
nodejs:
build: ./nodejs
@webuniverseio
webuniverseio / copy-node-sass-binaries-for-offline-install.js
Created June 26, 2017 16:06
Copy node-sass binaries for offline install
const fs = require('fs');
const xs =
fs.readdirSync('.')
.filter(x => x.endsWith('.node'))
//.map(x => (fs.mkdirSync(x.split('_')[0]), x))
.map(x => fs.writeFileSync(`${x.split('_')[0]}/binding.node`, fs.readFileSync(x)))
console.log(xs);
@webuniverseio
webuniverseio / csp
Created June 8, 2017 13:44 — forked from WebReflection/csp
Generates the right sha1 and sha256 for Content Security Policy aware scripts
#!/usr/bin/env bash
echo ''
if [ "$1" = "" ]; then
echo 'csp sha1 and sha256 generatoor'
echo 'csp "code"'
echo 'csp /file-name'
else
if [ -f "$1" ]; then
CONTENT=$(cat $1)
@webuniverseio
webuniverseio / readme.md
Last active May 6, 2017 15:56
Project scoped yarn
  • Checkout from git (switch to whatever commit is working for you)
  • run yarn from root
  • run yarn run build from root
  • remove .gitignore
  • remove tests, yarn-cache (-150 mb)
  • potentially clean up node_modules (flow-bin is like 25 mb)
  • test :)
  • commit
@webuniverseio
webuniverseio / forceUpdate.js
Created April 2, 2017 16:01
react-redux forceUpdate
componentDidMount() {
let prevState = this.props.getState();
this.unsubscribe =
this.props.subscribe(() => {
const state = this.props.getState();
if (state != prevState) {
this.forceUpdate();
prevState = state;
}
});