Skip to content

Instantly share code, notes, and snippets.

View dvgamerr's full-sized avatar

Kananek Thongkam dvgamerr

View GitHub Profile
@dvgamerr
dvgamerr / networking.md
Last active June 9, 2017 04:09
linux-command

Setup networking

vi /etc/network/interfaces
auto ens160
iface ens160 inet static
address 192.168.0.22
gateway 192.168.0.2
netmask 255.255.255.0
@dvgamerr
dvgamerr / webpack.common.md
Last active February 15, 2018 12:17
How to include Bootstrap 3 using webpack

1. Install dependencies

npm install jquery bootstrap-sass bootstrap-loader css-loader node-sass resolve-url-loader sass-loader style-loader url-loader --save-dev

Note: I'm not sure if all dependencies are indeed necessary. I used dependencies from #215 and added others to get it working for Bootstrap 3.

2. Configure Webpack

@dvgamerr
dvgamerr / regedit.md
Created February 15, 2018 13:52
regedit editor
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System
@dvgamerr
dvgamerr / advence-step.md
Last active March 28, 2018 08:05
Add autoincrement to existing PK

Using UPDATE, DELETE or INSERT to move data can take quite a lot of time and use resources (IO) on both data and log files/disks. It is possible to avoid filling the transaction log with potentially lots of records while working on a big table: Using partition switching, only the metadata is changed.

There is no data movement involved and this is therefore performed really quickly (almost instantaneous).

###Sample table

The question does not show the original table DDL. The following DDL will be used as an example in this answer:

CREATE TABLE dbo.idT(

id int not null

SELECT TOP 50
SUBSTRING(qt.TEXT, (qs.statement_start_offset/2)+1,
((
CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2)+1),
qs.execution_count,
(qs.total_logical_reads + qs.total_logical_writes) / qs.execution_count as [Avg IO],
qp.query_plan,
@dvgamerr
dvgamerr / fstab.ini
Created April 8, 2018 15:52
Linux Config files
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/PGM--SERVER--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=ee608de4-87ae-4fd4-a483-482ff96aef17 /boot ext2 defaults 0 2
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y
vi /etc/network/interfaces
auto enp0s25
iface enp0s25 inet static
address 192.168.1.2
gateway 192.168.1.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8 8.8.4.4
@dvgamerr
dvgamerr / bundle.sh
Created April 8, 2018 15:55
Gitlab Command
sysctl -w vm.max_map_count=262144
sudo chmod 700 /home/git/data/uploads
sudo chmod -R ug+rwX,o-rwx /home/git/data/repositories/
sudo chmod -R ug-s /home/git/data/repositories/
sudo find /home/git/data/repositories/ -type d -print0 | sudo xargs -0 chmod g+s
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
let charType = () => {
let group = [ 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2 ]
return group[parseInt(Math.random() * group.length)]
}
let charASCII = t => parseInt(Math.random() * (t === 0 ? 9 : 25))
const randomString = l => {
l = l || 32
let result = ''
for (let i = 0; i < l; i++) {
@dvgamerr
dvgamerr / Preferences.sublime-settings
Created April 23, 2018 09:41
Preferences.sublime-settings
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 10,