Skip to content

Instantly share code, notes, and snippets.

@so0k
so0k / S3-Angular-client.js
Last active October 27, 2015 04:16
S3 upload sample
function getS3Config() {
return Restangular.one(URLS.GET_S3_CONFIG).get();
}
//function with s3Config & angular $upload module injected
$upload.upload({
url: protocol + '://' + s3config.bucket + '/',
method: method.POST,
data: {
'key': funcs[i],
@so0k
so0k / Parse.ps1
Last active August 29, 2015 14:27
Read csv, parse HTML contained in csv field & return div elements of specific class exported as new csv
Function Get-FileName {
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = "Comma Separated files (*.csv)| *.csv"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
$Input = Get-FileName
@so0k
so0k / start.sh
Last active May 21, 2016 17:23
meteor up
#!/bin/bash
APPNAME=<%= appName %>
APP_PATH=/opt/$APPNAME
BUNDLE_PATH=$APP_PATH/current
ENV_FILE=$APP_PATH/config/env.list
PORT=<%= port %>
USE_LOCAL_MONGO=<%= useLocalMongo? "1" : "0" %>
# remove previous version of the app, if exists
@so0k
so0k / Query-Registry.ps1
Last active June 27, 2020 14:19
Query a docker registry v2/_catalog endpoint from powershell
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
$Filter=".*",
#TODO: handle https & no basic auth as well..
$RegistryEndpoint = "registry.mysite.com",
$UserName = "user",
$Password = "password"
)
@so0k
so0k / swapon.service
Last active August 4, 2016 09:39 — forked from romaninsh/swapon.service
Set up swap on CoreOS
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
Environment="SWAPFILE=/4GiB.swap"
RemainAfterExit=true
ExecStartPre=/usr/bin/touch ${SWAPFILE}
ExecStartPre=/usr/bin/chattr -C ${SWAPFILE}
ExecStartPre=/usr/bin/fallocate -l 4096m ${SWAPFILE}
CoreOS alpha (745.1.0)
core@kalimdor ~ $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bde18d705b86 sameersbn/gitlab:7.12.2-2 "/sbin/entrypoint.sh 6 days ago Up 26 seconds 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp gitlab
42b5896ee45e registry:2 "registry cmd/regist 3 weeks ago Up 29 seconds 0.0.0.0:5000->5000/tcp registry
eb05cf6fd7ec redis:3 "/entrypoint.sh redi 5 weeks ago Exited (0) 4 weeks ago dev-redis
4bb6c15f0b1c sameersbn/redmine:2.6.1 "/app/init app:start 3 months ago Up 26 seconds 443/tcp, 0.0.0.0:11080->80/tcp redmine
67d683ac603d nginx:latest "nginx -g 'daemon
#This gist expects msys git installed in path ${env:ProgramFiles(x86)}\Git\
$title = "Create CoreOS Docker host for Hyper-V"
$message = "Are you sure you want to start the setup for CoreOS, please ensure msys git has been installed first?"
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
"Confirm msys git is installed and it is safe to proceed with setup."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
"Cancel setup."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
switch ($result)
@so0k
so0k / demo-env.sh
Last active August 29, 2015 14:07
demoapp Docker environment - python & nodejs command line interface containers
#!/bin/bash
#this is old, do not use, use docker-compose instead
#demoapp env management script
#based on andreagrandi/glowmachine sample
#this script assumes it is running in the project folder
#under the data directory created by this boot2docker setup script:
#https://gist.github.com/so0k/d4f5e485a81ca5768643
@so0k
so0k / Set-localdocker.bat
Created August 22, 2014 11:52
CMD Batch that gets the boot2docker ip and updates the host file - powershell can't handle boot2docker ip command... Depends on Update-Hosts / Add-Hosts powershell scripts
@ECHO OFF
ECHO Getting boot2docker ip...
FOR /f "usebackq tokens=*" %%a IN (`boot2docker ip`) DO SET localdocker-ip=%%a
ECHO %localdocker-ip%
ECHO.
ECHO Analyzing hosts file
%windir%\System32\FIND /C /I "localdocker" %windir%\System32\drivers\etc\hosts
IF %ERRORLEVEL% NEQ 0 (
ECHO localdocker not found, adding to hosts...
powershell -command "Add-Hosts.ps1 -hostName \"localdocker\" -hostIp \"%localdocker-ip%\""
@so0k
so0k / Build-DockerContainers.ps1
Last active July 7, 2016 11:15
Powershell script to synchronize Boot2docker data and rebuild containers (depends on gm-env.sh & build_containers.sh & Set-localdocker.bat) - also requires Posh-SSH to be installed prior to using this script
Param(
[switch]$keepalive
)
#region script config
$dockerhost = "localdocker"
$User = "docker"
$PWord = (new-object System.Security.SecureString) #this is how you define blank password
$keyfile = "C:\Path\To\keys"
#endregion