Skip to content

Instantly share code, notes, and snippets.

@gscattolin
gscattolin / new_gist_file.sql
Created November 14, 2013 12:50
how-do-i-query-for-all-dates-greater-than-a-certain-date-in-sql-server
select *
from dbo.March2010 A
where A.Date >= Convert(datetime, '2010-04-01' )
@gscattolin
gscattolin / new_gist_file.js
Created January 10, 2014 11:20
Init function to pass the MVC server ViewModel 2 Knockout viewModel
$(function ()
{
require(['WorkOrderStatusConfiguration'], function (workOrderStatusConfig)
{
var data = $.parseJSON('@Html.Raw(Json.Encode(Model))');
workOrderStatusConfig.Init({
services: {
SaveWOConfigUrl: '@Url.Action("SaveWorkOrderConfiguration", "WorkOrderStatusConfiguration")',
},
bindingContainerId: 'WorkOrderStatusContainer',
@gscattolin
gscattolin / gist:9b214b20792467d27700
Created August 16, 2014 08:20
WPF Debug Bindings TraceLevel
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBlock Text="{Binding ThereIsNoDataContext,
diag:PresentationTraceSources.TraceLevel=High}"/>
</Grid>
</Window>
get add contains next remove(0) iterator.remove
ArrayList O(1) O(1) O(n) O(1) O(n) O(n)
LinkedList O(n) O(1) O(n) O(1) O(1) O(1)
CopyOnWrite-ArrayList O(1) O(n) O(n) O(1) O(n) O(n)
add contains next notes
HashSet O(1) O(1) O(h/n) h is the table capacity
LinkedHashSet O(1) O(1) O(1)
CopyOnWriteArraySet O(n) O(n) O(1)
EnumSet O(1) O(1) O(1)
# first make sure that the virtual machine is running
docker-machine start dev
Set environment variables to dictate that docker should run a command against a particular machine:
$ eval "$(docker-machine env dev)"
Check if environment is set:
$ env | grep DOCKER
DOCKER_HOST=tcp://192.168.99.100:2376
DOCKER_CERT_PATH=/Users/dm/.docker/machines/.client
DOCKER_TLS_VERIFY=1
@gscattolin
gscattolin / ElasticSearch queries
Last active March 14, 2021 09:01
Elastic search most common curls
curl 'localhost:9200/_cat/indices?v' => list of index
curl 'localhost:9200/_cluster/health?pretty' => health
curl -XGET 'http://localhost:9200/_mapping/twitter' => map of index twitter
curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
{
"size": 0,
"aggs": {
@gscattolin
gscattolin / MongoCommonCommands.txt
Last active August 15, 2016 05:38
MongoDb Most common commands
db.audit.remove({"reqTime" : { $lt : new Date('01/01/2016').getTime()}}) #remove everything is older than (bad performance)
db.audit.find().sort({"createdAt" : -1}).limit(1) #get latest created
db.collection.stats() #info about collection
export collection mongo in cvs file
mongoexport -h host -d dbname -c collectionname --type=csv -f name,side,type,field --out ~/export20160426.csv
db.fs.files.aggregate([{$group: {_id: "$contentType", total : { $sum: 1 }}}]) # count type on FS Grid
@gscattolin
gscattolin / gist:e2ecfc9e1abb20caf048f491943907a9
Created March 2, 2021 11:40
Reset Mariadb root password
systemctl stop mysqld / systemctl stop mariadb
service mysqld stop / service mariadb stop
mysqld --skip-grant-tables --user=root &
> mysql
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root_passowrd';
exit
@gscattolin
gscattolin / gist:bad761f70b7f8022fd9c533e27d2e1a4
Created March 22, 2021 11:39
Centos warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
vi /etc/environment
add these lines...
LANG=en_US.utf-8
LC_ALL=en_US.utf-8
@gscattolin
gscattolin / gist:fd28043e8931358631b33b9c0d2bb21c
Last active March 22, 2021 11:40
remove cached files after updating gitignore
git rm -rf --cached .
git add .
git commit -m ".gitignore caching"
push