Pages

Saturday, July 6, 2024

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

 Issue:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?


Fix:

  • sudo update-alternatives --config iptables
  • choose 1 : "/usr/sbin/iptables-legacy"
  • sudo service docker start
  • sudo service docker status

Wednesday, November 29, 2023

Generate Strong Password Using Bash Script

Generate Strong Password Using Bash Script

  • upper alphabeth
  • lower alphabeth
  • number
  • symbol


then combine and shuffle mix using Bash


pass1="$(head /dev/urandom | tr -dc 'A-Z' | head -c3)" # upper alphabeth
pass2="$(head /dev/urandom | tr -dc 'a-z' | head -c3)" # lower alphabeth
pass3="$(head /dev/urandom | tr -dc '0-9' | head -c3)" # number
pass4="$(head /dev/urandom | tr -dc '!@#$%^&*()' | head -c3)" # symbol
password=$pass1$pass2$pass3$pass4
mixed_password=$(echo "$password" | fold -w1 | shuf | tr -d '\n')
echo $mixed_password

Tuesday, July 5, 2022

git command for recreate feature branch

git command for recreate feature branch

git branch from tags


git branch mybranch001 tags/v1.0.0 git checkout mybranch001 git cherry-pick xxx git branch --set-upstream-to=origin/mybranch001 git push --force-with-lease

Wednesday, June 15, 2022

Powershell Append or Add Text into File

Powershell Append or Add Text into File

- Without Get-Content

- Dynamic call/execute command


$text = "texthere"

$cmd = "Add-Content -Path C:\xxx.txt -Value ""$text"""

for ($i = 0; $i -lt 1000; $i++) { Invoke-Expression $cmd }

Wednesday, December 1, 2021

AWS CLI using Role and MFA

 AWS CLI using Role and MFA

1. Setting AWS CLI Credential location : ~/.aws/credentials

[myuser]
aws_access_key_id = xxxx
aws_secret_access_key = xxxx


2. Setting AWS CLI Config location : ~/.aws/config

[profile myusermfa]
region = yourregion
role_arn = arn:aws:iam::xxAccountIDxx:role/xxRoleNamexx
source_profile = myuser
mfa_serial = arn:aws:iam::xxAccountIDxx:mfa/myuser
role_session_name = Session_MyUser_MFA

3. Access AWS CLI using profile

aws s3 ls s3:// --profile=myuser

Tuesday, October 5, 2021

Powershell Remove-Item Fast

Remove item in Windows via GUI will take some time because it will scan all files before delete.

To speed up time, we don't need to scan it.
One of fast method is using Powershell

Remove-Item -path ./* -recurse

Thursday, October 25, 2018

AWS S3 How to Find Files with by Keyword

open cmd
run command :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "Contents[?contains(Key, `SearchKeyword`)]"



How to sum :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "[sum(Contents[?contains(Key, `SearchKeyword`)].Size), length(Contents[?contains(Key, `SearchKeyword`)])]"

Wednesday, April 11, 2018

AWS S3 How to Count Folder Size

open cmd
run command :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "[sum(Contents[].Size), length(Contents[])]"

Monday, April 2, 2018

AWS cannot login RDP - Must change password before log in

AWS cannot login RDP - Must change password before log in

Error : "You must change your password before logging on the first time"



1. Open RDP
2. Connection Setting : click "Save As"
3. Save *.rdp file
4. Edit *.rdp file : add : enablecredsspsupport:i:0
5. Open RDP
6. Change password (with password policy)

How to delete files in folder using powershell

How to delete files in folder using powershell
Open Powershell

Run Command : Remove-Item –path c:\testfolder\* –recurse

* means any

Monday, October 16, 2017

How to using Windiff as External Diff in SourceTree

How to using Windiff as External Diff in SourceTree

1. Open SourceTree
2. Tools - Options
3. Diff - External Diff Tool : Custom
Diff command : C:\PathToWindiff\WinDiff.Exe
Argument :   $LOCAL $REMOTE

*note: put <space> in First letter in Argument
example in command prompt : WinDiff.Exe $LOCAL $REMOTE

Wednesday, August 30, 2017

How to compare file using Command Prompt and Visual Studio 2015

How to compare file using Command Prompt and Visual Studio 2015
1. open command prompt
2. go to visual studio path : "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"
3. example :
.\devenv.exe /diff “C:\b.txt” “C:\a.txt” “SOURCE” “TARGET”

Saturday, February 4, 2017

Copy Multi Folders using Robocopy for "Infinite Folders"

Intro dulu ya ....
gw lagi coding php, pake php designer 8. trus gw coba-coba toolsnya. ada export, eh pas gw coba, kok ga beres2 copynya?? trus gw cancel. pas gw liat, eh ternyata ngebuat folder yg banyak bgt.
gw coba cek pake software2, ada sekitar 475 folders (dibaca: tak terbatas a.k. infinity / infinite).
foldernya ampe ga bisa dibuka.
trus gw googling2.
- pake cmd , pake cara buat remove autorun.inf nya SMADAV seperti rmdir, rd, del, erase.
- install winUtilities, Unlocker, pake power shell, dsb.
- trus gw coba robocopy. pake cmd jg. setelah menggila lama , akhirnya nemu juga caranya. yaitu
robocopy [source] [dest] /purge /s /mov
contoh :  robocopy c:\hapus\a\ c:\delete\a\ /purge /s /mov

beres deh...

So, ini kesimpulannya :
Pakai Robocopy (using cmd)
command : 
robocopy [source] [dest] /purge /s /mov
contoh :  robocopy c:\hapus\a\ c:\delete\a\ /purge /s /mov

**dipublish setelah gw liat ini as draft (udah 4 tahun sepertinya...)

using Entity Framework or EF to copy an Object.

using Entity Framework or EF to copy an Object.
This can be used to avoid Error : PK cannot be modified :
"The property 'MyPrimaryKey' is part of the object's key information and cannot be modified. "
we can use this query :
var item = _context.MyTableName.First(z => z.Name == "Ardi");
var newItem = (MyTableName)_context.Entry(item).GetDatabaseValues().ToObject();
newItem.MyPrimaryKey = "Generated_" + DateTime.Now.ToString();
_context.SaveChanges();


Monday, September 16, 2013

How to import Huge SQL Script on mysql

open xampp Control Panel
click / open : shell

on shell type this commands:

1. command : "MYSQL -U USERNAME -H LOCALHOST -P PASSWORD"
USERNAME : your database username
PASSWORD : your database password
(if no password, then don't use "-P PASSWORD")

2. command : "USE NAME_OF_DATABASE"
 NAME_OF_DATABASE : name of your database

3. command : "SOURCE PATH_TO_SQL_FILE"
PATH_TO_SQL_FILE : location to script.sql
(ex. "source d:/myscript.sql")

4. done

Thursday, September 12, 2013

Firefox Text Bold Problem

I got my Firefox Text get Bold. This problem caused by regular Arial Font is missing. So, Arial Black is used.
To fix this, I got arial.ttf from http://www.fontsupply.com/fonts/A/Arial.html .
After you download, open arial.zip then open arial.ttf. Click install.
Your arial font will installed.
Problem done.

Tuesday, June 4, 2013

Creating ASPNET WebForm GridView Paging

Here is code for Creating ASPNET WebForm GridView Paging :

On *.aspx files, gridview need : properties AllowPaging and events OnPageIndexChanging
You can set and configure the pager style & setting by changing the PagerStyle and PagerSettings.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"  OnPageIndexChanging="GridView1_PageIndexChanging>
        <PagerStyle HorizontalAlign="Center" CssClass="foo" />
        <PagerSettings Mode="NumericFirstLast" PageButtonCount="5" FirstPageText="First" LastPageText="Last" />
</asp:GridView>

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
        GridView1.PageIndex = e.NewPageIndex;
        LoadData();
}

private void LoadData()
{
        GridView1.DataSource = mylist.ToList();
        GridView1.DataBind();
}

LoadData is a function to bind list or array to GridView. 
We can Manage the list by put them in a ViewState or in a Session to Keep Consistent List.
This could happend when you have searched list or sorted it.

Friday, March 8, 2013

SQL Server Rename Table Name

To rename table name in SQL Server , you can use this store procedure:
SP_RENAME 'TABLE_NAME' , 'NEW_TABLE_NAME' .
For example: sp_rename 'TFileFolder' , 'TFolder'
 

Saturday, February 11, 2012

CompiledQuery Linq to SQL C#

using CompiledQuery Linq to SQL C# using CompiledQuery can do more good performance and more efficient.
 using System.Data.Linq;
 public static Func> userData
        = CompiledQuery.Compile((myDataContext db) => db.TableUsers);

Using StopWatch to Count Execution Time in ASP.NET

Using Stopwatch to Count Execution Time in ASP.NET

 using System.Diagnostics;
 Stopwatch sw = new Stopwatch(); //create object
 sw.Start(); // start the stopwatch
 //do something here
 sw.Stop(); // stop the stopwatch
 Console.WriteLine("Time elapsed : " + sw.ElapsedMilliseconds.ToString());

ShareThis