Skip to content

Instantly share code, notes, and snippets.

View dhargitai's full-sized avatar
💭
Everything is awesome 😎

David Hargitai dhargitai

💭
Everything is awesome 😎
View GitHub Profile
@dhargitai
dhargitai / findAnagrams.js
Created March 2, 2020 13:45
My attempt to write an anagram finder function in Node by using functional programming paradigms.
const words = require('an-array-of-english-words');
const findAnagrams = (word, allWords) => {
const letters = word.split('')
const getNumberOfLetters = anArray => anArray.reduce((acc, letter) => ({
...acc,
[letter]: acc[letter] ? acc[letter] + 1 : 1,
}), {});
private difference(object1, object2) {
if (!object2 || Object.prototype.toString.call(object2) !== '[object Object]') {
return object1;
}
const differences = {};
let key;
const arraysMatch = (array1, array2) => {
if (array1.length !== array2.length) return false;
@dhargitai
dhargitai / slugify.js
Last active June 26, 2019 04:22 — forked from hagemann/slugify.js
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöőôœøṕŕßśșțùúüûǘűẃẍÿź·/_,:;'
const b = 'aaaaaaaaceeeeghiiiimnnnoooooooprssstuuuuuuwxyz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
Importing the production DB
prod-virgindotcom-virgindotcom-2016-05-06.sql.gz 100% 27MB 3.4MB/s 00:08
1462525921-virgin-prod-db-temp.sql.gz 100% 27MB 27.2MB/s 00:01
Set the tmp directory
file_temporary_path was set to "/tmp". [success]
WD memcache: Spent 112.8 ms splitting 2.07 MB object into 3 pieces, cid = virgin-dev-cache_views-views_data%3Aen [warning]
Disabling production only modules
cdn is already disabled. [ok]
There were no extens
@dhargitai
dhargitai / pull-from-stage.sh.output
Created May 6, 2016 08:35
./scripts/virginstartup.com/pull-from-stage.sh output
1462463816-virgin-startup-stage-db-temp.sql.gz 100% 305MB 50.8MB/s 00:06
Set the tmp directory
file_temporary_path was set to "/tmp". [success]
WD memcache: Spent 124.88 ms splitting 2.07 MB object into 3 pieces, cid = virgin-startup-dev-cache_views-views_data%3Aen [warning]
Disabling production only modules
Enabling all UI modules
views_ui is already enabled. [ok]
There were no extensions that could be enabled. [ok]
context_ui is alrea
root@web1:/var/www/szepul.hu# cat /etc/nginx/sites-enabled/default
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name szepul.hu.dev www.szepul.hu.dev;
root /var/www/szepul.hu/web;
index app_dev.php;
@dhargitai
dhargitai / Dockerfile
Last active August 29, 2015 14:26
Szepulhu dockerfile
FROM diatigrah/php-nginx-projectbase:0.2.1
RUN apt-get install -y ant && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD docker/services/php5-fpm/php.ini /etc/php5/fpm/conf.d/40-custom.ini
ADD docker/services/php5-fpm/php.ini /etc/php5/cli/conf.d/40-custom.ini
ADD docker/services/nginx/sites /etc/nginx/sites-enabled
@dhargitai
dhargitai / boot2docker-nfs.md
Last active August 29, 2015 14:18
boot2docker with NFS

My temporary solution is to use NFS shared folders instead of vboxfs, as vagrant does.

From osx "/etc/exports" (place this to the beginning of the file):

/Users -mapall=[youruser]:[yourgroup] [boot2dockerip]

Restart the nfs daemon in osx:

sudo nfsd stop && sudo nfsd start
<?php
/**
* Error reporting
*/
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
/**
* Compilation includes configuration file
*/
#!/bin/sh
mysqldump --single-transaction \
--ignore-table=DBNAME.catalog_category_anc_categs_index_idx \
--ignore-table=DBNAME.catalog_category_anc_categs_index_tmp \
--ignore-table=DBNAME.catalog_category_anc_products_index_idx \
--ignore-table=DBNAME.catalog_category_anc_products_index_tmp \
--ignore-table=DBNAME.catalog_category_product_index \
--ignore-table=DBNAME.catalog_category_product_index_enbl_idx \
--ignore-table=DBNAME.catalog_category_product_index_enbl_tmp \