Skip to content

Instantly share code, notes, and snippets.

@ilguzin
ilguzin / Dockerfile
Created May 29, 2019
Use GitHub as your private NPM registry within your Dockerfile
View Dockerfile
FROM ...
ARG GITHUB_TOKEN # GITHUB_TOKEN is only defined for build stage! https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
RUN apk add git # This might contain more system packages depending on what is about to be installed by NPM
RUN git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com".insteadOf ssh://git@github.com # Force NPM to use https://${GITHUB_TOKEN}:x-oauth-basic@github.com/<user name>/<repository>.git for modules installed from GitHub
COPY package.json /package.json
@ilguzin
ilguzin / docker_adjust_memory.sh
Created May 24, 2019 — forked from scotthaleen/docker_adjust_memory.sh
Adjust Docker Machine Memory & CPU
View docker_adjust_memory.sh
# Adjust Docker Machine Memory+CPU
# http://stackoverflow.com/questions/32834082/how-to-increase-docker-machine-memory-mac
docker-machine stop
VBoxManage modifyvm default --cpus 2
VBoxManage modifyvm default --memory 4096
docker-machine start
@ilguzin
ilguzin / .nvmrc
Created Jun 14, 2018
VS Code NodeJS settings.
@ilguzin
ilguzin / env.py
Created Jun 1, 2018 — forked from lethee/env.py
Sublime Text 3: Apply NVM environment
View env.py
# Save this file
# mac - "~/Library/Application Support/Sublime Text 3/Packages/"
# linux - "~/.config/sublime-text-3/Packages/"
# NOTE!
# ~/.nvm/alias/default must contain full version name.
# $ nvm alias default v4.3.5
import os
@ilguzin
ilguzin / app.js
Last active Dec 9, 2015
Embedding ui-select into ui-grid cell
View app.js
app.run(['$templateCache', function ($templateCache) {
/**
* Cached Angular Template for ui-grid/uiSelect.
* Allows to use in ui-grid as 'editableCellTemplate' field definition
*/
$templateCache.put('ui-grid/uiSelect',
'<ui-select-grid-cell-wrap>' +
'<ui-select ng-model="MODEL_COL_FIELD" theme="selectize" ng-disabled="disabled" append-to-body="true">' +
'<ui-select-match placeholder="Choose...">{{ $select.selected[editDropdownValueLabel] }}</ui-select-match>' +
View dashboardCtrl.coffee
class dashboardCtrl
NOTIFICATIONS_STATUS_UPDATE_PERIOD = 30 # Seconds
@$inject = ['$scope', '$q', '$log', '$cookies', '$state', '$rootScope', '$timeout', 'MonitoringService',
'loginService', 'SettingsService']
_s = {}
scheduleAgentDataUpdate = () ->
@ilguzin
ilguzin / gist:ff58a8376228234e1e5b
Last active Aug 29, 2015
WordPress's workaround for is_ssl() function when proxying from https to http. HTTP_X_FORWARDED_PROTO feature. Stolen from https://wordpress.org/support/topic/request-modify-is_ssl-function-to-check-for-http_x_forwarded_proto
View gist:ff58a8376228234e1e5b
/**
* Determine if SSL is used.
*
* @since 2.6.0
*
* @return bool True if SSL, false if not used.
*/
function is_ssl() {
if ( isset($_SERVER['HTTPS']) ) {
if ( 'on' == strtolower($_SERVER['HTTPS']) )
@ilguzin
ilguzin / content.html
Last active Aug 29, 2015
Average color of the picture. Stolen from http://jsfiddle.net/xLF38/ . Get data uri from image http://dataurl.net/#dataurlmaker
View content.html
Setting the BODY's background to the average color in the following image:
<br/><br/>
<img id="i" src="data:image/jpeg;base64,/9j/7gAOQWRvYmUAZAAAAA........Q==" />
@ilguzin
ilguzin / color2text_brightness.coffee
Last active Aug 29, 2015
Derive text color depending on background brightness
View color2text_brightness.coffee
#Color text change
rgb = [
"255"
"0"
"0"
]
setInterval (->
c = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")"
#http://www.w3.org/TR/AERT#color-contrast
View deny_copy_paste.js
<script type="text/javascript">
document.ondragstart = noselect;
document.onselectstart = noselect;
document.oncontextmenu = noselect;
function noselect() {return false;}
</script>