Skip to content

Instantly share code, notes, and snippets.

View vojty's full-sized avatar
🦦

Tomáš Vojtášek vojty

🦦
View GitHub Profile
SunCalc = (function() {
var J1970 = 2440588,
J2000 = 2451545,
deg2rad = Math.PI / 180,
M0 = 357.5291 * deg2rad,
M1 = 0.98560028 * deg2rad,
J0 = 0.0009,
J1 = 0.0053,
J2 = -0.0069,
C1 = 1.9148 * deg2rad,
@vojty
vojty / prettier_format.ts
Created November 26, 2021 07:04
Prettier node usage
import prettierConfig from './.prettierrc'
const code = 'const foo = 1; const bar = 2;'
const out = prettier.format(code, {
...prettierConfig,
parser: 'typescript'
})
console.log(out)
@vojty
vojty / readme.md
Created October 1, 2021 07:02
Route specific domain via custom DNS server
@vojty
vojty / osxvpnrouting.markdown
Created July 9, 2021 08:55 — forked from taldanzig/osxvpnrouting.markdown
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

@vojty
vojty / MarkdownPage.tsx
Created February 18, 2021 11:40 — forked from jaredpalmer/MarkdownPage.tsx
Get headers from MDX in Next.js
import {MDXProvider} from '@mdx-js/react';
import {MDXComponents} from 'components/MDX/MDXComponents';
import {Toc} from 'components/Toc/Toc';
import * as React from 'react';
export interface MarkdownProps<Frontmatter> {
meta: Frontmatter;
children?: React.ReactNode;
}
@vojty
vojty / gist:284600631dcdb6e57de3f54a22e911e2
Created December 21, 2017 15:45
Enzyme 3.2 + React-portal
const portalComponent = wrapper.find(Portal).at(0);
const portalInstance = portalComponent.instance();
const portalWrapper = new ReactWrapper(portalInstance.props.children);
portalWrapper.find(...)
@vojty
vojty / branfuck.js
Created November 12, 2016 18:11
Brainfuck.js
function branfuck(code, input){
const output = [];
const data = [];
let dataPointer = 0;
let inputPointer = 0;
let inputArr = input.split('').map(i => i.codePointAt(0))
const chars = code.split('');
let codePointer = 0;
@vojty
vojty / download.sh
Created August 28, 2015 13:16
Let's get excited
#!/bin/bash
youtube-dl --extract-audio --audio-format "mp3" --audio-quality 1 --batch-file "list.txt"
@vojty
vojty / User.php
Last active November 25, 2015 14:29 — forked from Ocramius/User.php
Doctrine ManyToMany Setters
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity()
* @ORM\Table(name="user")
*/
class User
@vojty
vojty / backup.sh
Created June 17, 2015 14:53
MySQL backups
#!/bin/bash
now=$(date +"%Y-%m-%d")
mysqlUser="root"
mysqlPass="xxx"
server="[email protected]"
log="./backup_sql.log"