Skip to content

Instantly share code, notes, and snippets.

' MS Access VBA: export to Excel and create a pivot table
Dim TheDate As Date
TheDate = Now()
Dim strFilePath As String
strFilePath = "C:\Temp\filename_" & Month(TheDate) & "-" & Day(TheDate) & "-" & Year(TheDate) & ".xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "my_query_here", strFilePath, True
Public Function MakeExcelPivot() As Boolean
On Error GoTo Err_MakeExcelPivot
Dim TheDate As Date
TheDate = Now()
Dim strFilePath As String
strFilePath = "D:\blah" & Month(TheDate) & "-" & Day(TheDate) & "-" & Year(TheDate) & ".xls"
If Len(Dir(strFilePath)) > 0 Then
@stevesohcot
stevesohcot / webview.swift
Created May 8, 2016 17:28
Sample Webview using Swift with Progress Indicator
// http://stevesohcot.com/tech-lessons-learned/2016/05/08/webview-using-swift-with-progress-indicator-tutorial
import UIKit
class ViewController: UIViewController, UIWebViewDelegate {
@IBOutlet weak var webView: UIWebView!
@IBOutlet weak var progressIndicator: UIActivityIndicatorView!
override func viewDidLoad() {
@stevesohcot
stevesohcot / base_controller.rb
Created May 11, 2016 00:54
Rails Admin Namespace - Base Controller
# http://stevesohcot.com/tech-lessons-learned/2016/05/11/rails-create-admin-namespace
# /app/controllers/admin/base_controller.rb
class Admin::BaseController < ApplicationController
before_action :admin_only
layout "admin"
private
@stevesohcot
stevesohcot / MainActivity.java
Created May 15, 2016 21:34
Andoird WebView sample - MainActivity.java
// http://stevesohcot.com/tech-lessons-learned/2016/05/15/android-webview-sample-code/
package com.diamondium.hashtagsaver;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
@stevesohcot
stevesohcot / AndroidManifest.xml
Created May 15, 2016 21:36
Android Webview sample - AndroidManifest.xml
// http://stevesohcot.com/tech-lessons-learned/2016/05/15/android-webview-sample-code
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.diamondium.hashtagsaver" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@stevesohcot
stevesohcot / activity_main.xml
Created May 15, 2016 21:37
Android Webview - Activity Main
// http://stevesohcot.com/tech-lessons-learned/2016/05/15/android-webview-sample-code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:layout_width="fill_parent"
@stevesohcot
stevesohcot / MainActivity.java
Created May 15, 2016 22:44
Android Webview open URLs in new browser window
// http://stevesohcot.com/tech-lessons-learned/2016/05/15/android-cannot-resolve-method-startactivityandroid-content-intent
package com.diamondium.hashtagsaver;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
// Needed to open URLs in a new window
@stevesohcot
stevesohcot / excel_sql_server.vba
Created May 17, 2016 00:33
Import data from SQL Server into Excel
// http://stevesohcot.com/tech-lessons-learned/2016/05/17/get-data-from-sql-server-in-excel
Public Sub GetData()
Dim strSQL As String
Dim strCnn As String
Dim cnn As Object
Dim rst As Object
strCnn = "Driver={SQL Server};" & _
@stevesohcot
stevesohcot / database_connection.php
Created June 19, 2016 14:39
Sample connection to local PHP/MySQL using XAMPP
<h1>Connect to a database</h1>
<?php
// http://stevesohcot.com/tech-lessons-learned/2016/06/19/xampp-php-setup-on-a-mac/
// Sample connection to local PHP/MySQL using XAMPP
$host = "localhost";
$user = "root";
$password = "";
$db1 = mysqli_connect($host, $user, $password, "MyDatabase") or die ("Could not connect");