Skip to content

Instantly share code, notes, and snippets.

View priesdelly's full-sized avatar
🏠
Working from home

Priesdelly priesdelly

🏠
Working from home
View GitHub Profile
@priesdelly
priesdelly / StringBuilder.cs
Last active February 23, 2019 09:59
Example use "System.Text.StringBuilder" in .NET framework by C# language
using System;
using System.Diagnostics;
using System.Text;
namespace StringBuilder
{
class Program
{
static void Main(string[] args)
{
@priesdelly
priesdelly / DateCultureCSharp.cs
Last active February 24, 2019 05:53
Date, Datetime show in other culture info
using System;
using System.Collections.Generic;
using System.Text;
// นำเข้าคลาส Globalization โดยเรียกผ่านเนมสเปช System.Globalization
// เพื่อให้สามารถเรียกใช้คลาส CultureInfo() ได้
using System.Globalization;
namespace DateCultureCSharp
{
@priesdelly
priesdelly / DateCultureCShapre2.cs
Last active February 24, 2019 06:28
Create 12 month via code in .NET Framework
private void Form1_Load(object sender, EventArgs e)
{
for (int monthNo = 1; monthNo < 12; monthNo++)
{
var bar = new DateTime(DateTime.Now.Year, monthNo, 1);
listBox1.Items.Add(bar.ToString("MMMM", new CultureInfo("en-US")));
listBox2.Items.Add(bar.ToString("MMMM", new CultureInfo("th-TH")));
}
}
private string GetExcelColumnName(int columnNumber)
{
int dividend = columnNumber;
string columnName = String.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
@priesdelly
priesdelly / ReplaceStringJSNormal.js
Last active February 24, 2019 07:12
Replace string in javascript
var strText = 'Test Replace bear and duck and dog and cat';
var strAfRep = strText.replace('and','or');
console.log(strAfRep);
@priesdelly
priesdelly / ReplaceStringJSNew.js
Created February 24, 2019 07:13
Replace string in javascript
var strText = 'Test Replace bear and duck and dog and cat';
var strAfRep = strText.replace(/and/g,'or');
console.log(strAfRep);
@priesdelly
priesdelly / NonStaticMethod.java
Last active February 24, 2019 07:29
Example static method
public class TestStaticMethod{
public static void main(String[] args){
Calculate foo = new Calculate();
int value = foo.bar(10);
System.out.println("value = " + value);
}
}
class Calculate{
public int bar(int number){
@priesdelly
priesdelly / StaticMethod.java
Last active February 24, 2019 07:29
Example static method
public class TestStaticMethod{
public static void main(String[] args){
int value = Calculate.bar(10);
System.out.println("value = " + value);
}
}
class Calculate{
public static int bar(int number){
return number+10;
@priesdelly
priesdelly / TestModel.java
Last active February 24, 2019 09:16
Model class for example test in java
class TestModel {
private static int value1;
private int value2;
public static int getValue1() {
return value1;
}
public static void setValue1(int value1) {
TestModel.value1 = value1;
@priesdelly
priesdelly / StaticVariable.java
Created February 24, 2019 09:21
Example static variable
import java.util.ArrayList;
public class TestStaticVariable {
public static void main(String[] args) {
ArrayList < TestModel > modelLst = new ArrayList < > ();
for (int i = 0; i < 10; i++) {
TestModel model = new TestModel();