Skip to content

Instantly share code, notes, and snippets.

@ilguzin
ilguzin / Dockerfile
Created May 29, 2019 07:59
Use GitHub as your private NPM registry within your 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}:[email protected]".insteadOf ssh://[email protected] # Force NPM to use https://${GITHUB_TOKEN}:[email protected]/<user name>/<repository>.git for modules installed from GitHub
COPY package.json /package.json
@ilguzin
ilguzin / docker_adjust_memory.sh
Created May 24, 2019 10:29 — forked from scotthaleen/docker_adjust_memory.sh
Adjust Docker Machine Memory & CPU
# 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 June 14, 2018 06:04
VS Code NodeJS settings.
0.12
@ilguzin
ilguzin / env.py
Created June 1, 2018 13:40 — forked from lethee/env.py
Sublime Text 3: Apply NVM environment
# 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 December 9, 2015 07:11
Embedding ui-select into ui-grid cell
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>' +
@ilguzin
ilguzin / dashboardCtrl.coffee
Last active August 29, 2015 14:24
example code
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 August 29, 2015 14:21
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
/**
* 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 August 29, 2015 14:08
Average color of the picture. Stolen from http://jsfiddle.net/xLF38/ . Get data uri from image http://dataurl.net/#dataurlmaker
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 August 29, 2015 14:08
Derive text color depending on background brightness
#Color text change
rgb = [
"255"
"0"
"0"
]
setInterval (->
c = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")"
#http://www.w3.org/TR/AERT#color-contrast
@ilguzin
ilguzin / deny_copy_paste.js
Created October 15, 2014 06:02
Deny copy paste JS
<script type="text/javascript">
document.ondragstart = noselect;
document.onselectstart = noselect;
document.oncontextmenu = noselect;
function noselect() {return false;}
</script>