Skip to content

Instantly share code, notes, and snippets.

@orette
orette / CopyColumnsDataView.cs
Last active August 29, 2015 14:10
Copy columns between Data Tables
System.Data.DataView view = new System.Data.DataView(sourceTable);
System.Data.DataTable selected = view.ToTable("Selected", false, "col1", "col2", "col6", "col7", "col3");
@orette
orette / ChangeDataTableColumnType.cs
Last active August 29, 2015 14:10
Change column type after DataTable is populated
//You cannot change the DataType of a DataColumn after populating it with data.
//An exception is generated when changing this property after the column has begun storing data.
public DataTable CloneOriginalTableThenChangeColumnType(DataTable dt)
{
DataTable dtCloned = dt.Clone();
dtCloned.Columns[0].DataType = typeof(string);
foreach (DataRow row in dt.Rows)
{
dtCloned.ImportRow(row);
@orette
orette / mssql-snippets.sql
Last active August 29, 2015 14:10
MSSQL Snippets
-- Get a list of microsoft sql server agent jobs
--1
SELECT job_id, [name] FROM msdb.dbo.sysjobs;
--2
USE msdb
EXEC dbo.sp_help_job
-- Get a list of microsoft sql server agent jobs with steps
SELECT
job.job_id,
@orette
orette / vi-cheat-sheet-cursor-movement
Last active February 18, 2026 05:25
vi Cheat Sheet
Cursor Movment
h - move left
j - move down
k - move up
l - move right
w - jump by start of words (punctuation considered words)
W - jump by words (spaces separate words)
e - jump to end of words (punctuation considered words)
E - jump to end of words (no punctuation)
@orette
orette / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@orette
orette / javascript_resources.md
Last active August 29, 2015 14:11 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@orette
orette / move-sql-server-database-files.sql
Last active August 29, 2015 14:17
Change the location of an SQL Server database file
--Get the logical name of the database and log file
USE tempdb
GO
EXEC sp_helpfile
GO
--Change database location
USE master
GO
ALTER DATABASE tempdb
@orette
orette / as400-journals
Created March 23, 2015 16:47
Journal a file on an IBM iSeries (AS400)
//List Journals
WRKOBJ OBJ(*ALL/*ALL) OBJTYPE(*JRN)
//Journal a file
STRJRNPF FILE({Library}/{File}) JRN({Library}/{File})
@orette
orette / mssql-running-total.sql
Created March 23, 2015 20:34
Calculating simple running totals in SQL Server
--Source : http://www.codeproject.com/Articles/300785/Calculating-simple-running-totals-in-SQL-Server
--First we need a table for the data. To keep things simple, let's create a table with just an auto incremented id and a value field.
CREATE TABLE RunTotalTestData (
id int not null identity(1,1) primary key,
value int not null
);
--And populate it with some data:
INSERT INTO RunTotalTestData (value) VALUES (1);
@orette
orette / mssql-copy-table-with-data.sql
Last active August 29, 2015 14:21
Backup MSSQL table
-- ##Export Table
use <database>
DECLARE @table VARCHAR(128),
@file VARCHAR(255),
@cmd VARCHAR(512)
-- Replace <table name> table Name which you want to backup
SET @table = '<table name>'
-- Replace <destination folder> to destination dir where you want to place table data backu
SET @file = '<destination folder>' + @table + '_' + CONVERT(CHAR(8), GETDATE(), 112) + '.dat'
-- You must have bulk import / export privileges