Skip to content

Instantly share code, notes, and snippets.

@KensoDev
KensoDev / s3_folder_upload.rb
Created March 7, 2014 14:52
S3 Folder upload
require 'aws'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
# Initialize the upload class
#
# folder_path - path to the folder that you want to upload
# bucket - The bucket you want to upload to
@KensoDev
KensoDev / launch-server.sh
Created July 17, 2014 19:19
create new web server using the ec2-tools
#!/bin/bash
region=us-west-2
ami=ami-927613a2
# http://cloud-images.ubuntu.com/locator/ec2/
echo "Input server name: "
read server_name
USERDATA=$(cat <<-EOF
@KensoDev
KensoDev / 23-nginx-access
Created December 10, 2014 14:25
Ship Logs to logstash using Rsyslog
$ModLoad imfile # Load the imfile input module
# <syslog-tag> Tag you give to syslog in order to identigy the input coming from this file eg: nginx-access/rails/some_other_name
# <statefile-name> What do you want the state file to be called eg: nginx-access-state
# use @@ if you want to send logs over TCP
# use @ if you want to send logs over UDP
$InputFileName /path/to_log_location.log
$InputFileTag <syslog-tag>:
$InputFileStateFile <statefile-name>
diff -ur orig/ext/readline/readline.c fixed/ext/readline/readline.c
--- orig/ext/readline/readline.c 2014-03-18 13:53:31.866359527 +0100
+++ fixed/ext/readline/readline.c 2014-03-18 13:56:26.390247250 +0100
@@ -1883,7 +1883,7 @@
rl_attempted_completion_function = readline_attempted_completion_function;
#if defined(HAVE_RL_PRE_INPUT_HOOK)
- rl_pre_input_hook = (Function *)readline_pre_input_hook;
+ rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
#endif
@KensoDev
KensoDev / list-instance-types.sh
Created April 7, 2015 16:21
GET list of running instance types on Amazon
ec2-describe-instances | grep running | awk '{print $9}'
IF EXISTS(select * from sysobjects where id = object_id('dbo.SP_ShrinkAllDatabasesOnServer') and xtype = 'P')
DROP PROCEDURE dbo.SP_ShrinkAllDatabasesOnServer
GO
CREATE PROCEDURE dbo.SP_ShrinkAllDatabasesOnServer
AS
BEGIN
CREATE TABLE #TempDatabasesTable
(
[DatabaseName] sysname not null primary key,
DECLARE @DatabaseName varchar(100), @SqlStatement varchar(1024)
SET ROWCOUNT 1
SELECT @DatabaseName = NAME FROM SYSDATABASES ORDER BY NAME
WHILE @@ROWCOUNT > 0
BEGIN
SET @SqlStatement = 'ALTER TABLE tblUsers ALTER COLUMN email nvarchar(250) NOT NULL'
SELECT @SqlStatement = 'Use [' + @DatabaseName + '] exec (' + @SqlStatement + ')'
PRINT (@SqlStatement)
SELECT @DatabaseName = NAME FROM SYSDATABASES WHERE NAME > @DatabaseName
DECLARE @DatabaseName varchar(100), @SqlStatement varchar(1024)
SET ROWCOUNT 1
SELECT @DatabaseName = NAME FROM SYSDATABASES ORDER BY NAME
WHILE @@ROWCOUNT > 0
BEGIN
-- Change this to your own SQL statement you want to execute against your db's
SET @SqlStatement = 'ALTER TABLE tblUsers ALTER COLUMN email nvarchar(250) NOT NULL'
SELECT @SqlStatement = 'Use [' + @DatabaseName + '] exec (' + @SqlStatement + ')'
-- Print the command to the screen
/// <summary>
/// credit card number and an attached weight number
/// </summary>
public class CreditCardNumbers
{
public int number { get; set; }
public int weightNumber { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="CreditCardNumbers"/> class.
/// <summary>
/// Determines whether [is odd number] [the specified number].
/// </summary>
/// <param name="number">The number.</param>
/// <returns>
/// <c>true</c> if [is odd number] [the specified number]; otherwise, <c>false</c>.
/// </returns>
public static bool isOddNumber(int number)
{
if (number % 2 == 0)