This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cx_Oracle | |
class OracleWrapper(object): | |
""" | |
A class for handling db operations | |
""" | |
def __init__(self, constring): | |
self.constring = constring.strip() | |
self.db_connection = cx_Oracle.connect(constring) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
p = subprocess.Popen(["ntpq", "-p"], stdout=subprocess.PIPE) # ["command", "arg1", "arg2", "so on"] | |
out, err = p.communicate() | |
#you can then use out.split("\n") to get outputs as a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage: Apple myAppleVar = Fruit<Apple>.CreateInstance(); | |
// ref: http://stackoverflow.com/questions/1380087/whats-the-correct-alternative-to-static-method-inheritance-c | |
public abstract class Fruit<T> | |
where T : Fruit<T>, new() | |
{ | |
public static T CreateInstance() | |
{ | |
T newFruit = new T(); | |
newFruit.Initialize(); // Calls Apple.Initialize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title = u"Klüft skräms inför på fédéral électoral große" | |
import unicodedata | |
unicodedata.normalize('NFKD', title).encode('ascii','ignore') | |
'Kluft skrams infor pa federal electoral groe' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$YOURFILE = "example.txt"; | |
$nlines = 0; | |
#read file by 1000 lines at a time | |
gc $YOURFILE -read 1000 | % { $nlines += $_.Length }; | |
[string]::Format("{0} has {1} lines", $YOURFILE, $nlines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dapper; | |
using Oracle.ManagedDataAccess.Client; | |
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Linq; | |
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters { | |
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example of using elastic's BulkProcessor with Elasticsearch. | |
// | |
// See https://github.com/olivere/elastic and | |
// and https://github.com/olivere/elastic/wiki/BulkProcessor | |
// for more details. | |
/* | |
* This example illustrates a simple process that performs bulk processing | |
* with Elasticsearch using the BulkProcessor in elastic. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// true-type-of.js | |
export const trueTypeOf = input => Object.prototype.toString.call(input) | |
.replace(/(\[object |\])/ig, '') | |
.toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Papa from 'papaparse'; | |
import { saveAs } from 'file-saver/FileSaver'; | |
export default async ({ payload, filename }) => { | |
saveAs( | |
new Blob([Papa.unparse(payload)], { type: 'text/plain;charset=utf-8' }), | |
`${filename}.csv` | |
); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters\ /v AllowEncryptionOracle /t REG_DWORD /d 2 |
OlderNewer