Skip to content

Instantly share code, notes, and snippets.

View aklesky's full-sized avatar
🏠
Working from home

Aleksei Semiglasov aklesky

🏠
Working from home
View GitHub Profile
@aklesky
aklesky / add_python_to_WINDOWS_WSL_ubuntu.md
Created July 27, 2023 08:10 — forked from monkut/add_python_to_WINDOWS_WSL_ubuntu.md
Add python to Windows Subsystem for Linux (WSL) [ubuntu]
@aklesky
aklesky / Instructions.md
Created June 19, 2023 20:10 — forked from Mairu/Instructions.md
Script to enable dnsmasq in ubuntu/debian in wsl2 (win11) on system start

Problem

When using WSL2 npm install dns lookup is very slow. To increase the speed you can use an alternative dns server. If you still need the configured dns server, for example because of vpn usage etc multiple dns servers are needed.

Solution

Install dnsmasq inside the WSL distribution.

On ubuntu: sudo apt install dnsmasq

@aklesky
aklesky / slim-redux.js
Created October 23, 2019 11:46 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@aklesky
aklesky / osx-setup.sh
Created April 25, 2019 12:32 — forked from somebox/osx-setup.sh
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc
@aklesky
aklesky / wp_insert_attachment_from_url.php
Created January 22, 2019 14:13 — forked from m1r0/wp_insert_attachment_from_url.php
WP: Insert attachment from URL
<?php
/**
* Insert an attachment from an URL address.
*
* @param String $url
* @param Int $parent_post_id
* @return Int Attachment ID
*/
function crb_insert_attachment_from_url($url, $parent_post_id = null) {
@aklesky
aklesky / iOS-icons.html
Created July 9, 2017 12:15 — forked from galenandrew/iOS-icons.html
iOS icon meta links
<!-- non-retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="icon57.png" sizes="57x57">
<!-- non-retina iPad pre iOS 7 -->
<link rel="apple-touch-icon" href="icon72.png" sizes="72x72">
<!-- non-retina iPad iOS 7 -->
<link rel="apple-touch-icon" href="icon76.png" sizes="76x76">
<!-- retina iPhone pre iOS 7 -->
<link rel="apple-touch-icon" href="icon114.png" sizes="114x114">
<!-- retina iPhone iOS 7 -->
<link rel="apple-touch-icon" href="icon120.png" sizes="120x120">
@aklesky
aklesky / circle.yml
Created May 16, 2017 11:56 — forked from benjamincharity/circle.yml
CircleCI deploy to NPM
machine:
node:
version: 6.9.5
dependencies:
pre:
- 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
test:
override:
- rm -rf $CIRCLE_ARTIFACTS/coverage
@aklesky
aklesky / eloquent.md
Last active August 29, 2015 14:14 — forked from msurguy/eloquent.md

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@aklesky
aklesky / formSpec.js
Last active August 29, 2015 14:11
Simulate AJax Response
define(['jquery'], function ($) {
describe("Form suite", function () {
it('jQuery must be defined', function () {
expect($).toBeDefined();
});
it('Testing jQuery Ajax Call', function () {
var d = $.Deferred();
@aklesky
aklesky / phpSingletone.php
Created December 4, 2014 17:05
PHP Singletone
<?php
static public function getInstance()
{
static $instance;
$class = get_called_class();
if (!($instance instanceof $class)) {
$reflection = new \ReflectionClass($class);
$instance = $reflection->newInstanceArgs(func_get_args());