Skip to content

Instantly share code, notes, and snippets.

View slava-sh's full-sized avatar

Slava Shklyaev slava-sh

View GitHub Profile
@jgamblin
jgamblin / Sysinfo.sh
Last active August 8, 2023 06:46
A Bash Script To Get System Information For OSX.
#!/bin/bash
# You Will need to install iStats
# gem install istats
echo && echo ———————-System Information:——————— &&
/bin/echo -n "Uptime: " && uptime | awk '{print $3}'
echo
/bin/echo -n "CPU Usage: " && top -l 1 | awk '/CPU usage/ {print $3}'
/bin/echo -n "CPU Temp: " && istats | grep CPU\ temp | awk '{print $3}'
/bin/echo -n "FAN Speed: " && istats | grep Fan\ 0\ speed: | awk '{print $4,$5}'
@HenrikJoreteg
HenrikJoreteg / README.md
Last active September 20, 2021 01:36
Minimalist routing in Redux

Why would you want to do this? Because you often don't need more. It's nice to not have to think about your "router" as this big special thing.

Instead, with this approch, your app's current pathname is just another piece of state, just like anything else.

This also means that when doing server-side rendering of a redux app, you can just do:

var app = require('your/redux/app')
var React = require('react')
@freekmurze
freekmurze / deploy.php
Last active February 5, 2021 02:43
A sample deploy.php file that can be used with Deployer (http://deployer.in)
<?php
/*
* Define the servers
*/
server('production-web', '<your server url>')
->path('<path to the project on your server>')
->user('<user on the server>')
->pubKey();
/*
@cjohansen
cjohansen / gist:4135065
Created November 23, 2012 10:43
Naming this in nested functions

tl;dr

If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.

In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.

Naming this in nested functions

I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.

Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.

@mbijon
mbijon / wordpress-plugin-api.php
Created November 2, 2011 00:38
WordPress plugin API sample-use
<?php
/*
Retrieve items from the WordPress.org plugin API
Original source: http://pastebin.com/7Ji8rD2P
Docs v1.0: http://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/
Usage:
http://{host}/wordpress-plugin-api.php?page_start=9&per=20&pages=10&info=1
GET['page_start'] => Page-numer to start retreiving data on
@tbranyen
tbranyen / backbone_pushstate_router.js
Last active February 25, 2024 21:38
hijack links for pushState in Backbone
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.