Skip to content

Instantly share code, notes, and snippets.

View amertkara's full-sized avatar

Mert Kara amertkara

View GitHub Profile
@amertkara
amertkara / cask_upgrade.sh
Created September 17, 2017 23:09
Script upgrading outdated brew casks
#!/usr/bin/env bash
(set -x; brew update;)
(set -x; brew cleanup;)
(set -x; brew cask cleanup;)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
@amertkara
amertkara / AnalyzerCommand.java
Last active March 6, 2016 18:10
SpringBoot CommandLineRunner
package com.amertkara.springframework.multiplerunners.subcommands.analyzer;
import org.apache.commons.cli.*;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class AnalyzerCommand implements CommandLineRunner {
@amertkara
amertkara / create_user.sh
Last active December 20, 2015 17:36
Installing Jenkins on OSX Server
sudo /usr/sbin/dseditgroup -o create -r 'Jenkins CI Group' -i 600 _jenkins
sudo dscl . -append /Groups/_jenkins passwd "*"
sudo dscl . -create /Users/_jenkins
sudo dscl . -append /Users/_jenkins RecordName jenkins
sudo dscl . -append /Users/_jenkins RealName "Jenkins CI Server"
sudo dscl . -append /Users/_jenkins uid 600
sudo dscl . -append /Users/_jenkins gid 600
sudo dscl . -append /Users/_jenkins shell /usr/bin/false
sudo dscl . -append /Users/_jenkins home /var/jenkins
sudo dscl . -append /Users/_jenkins passwd "*"
@amertkara
amertkara / ivy.xml
Created May 7, 2015 15:49
ivy assets
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="com.amertkara" module="module-name-comes-here" revision="0.1"/>
<publications>
<artifact type="jar" name="jar-name" conf="default" />
</publications>
@amertkara
amertkara / wp-config extras
Created February 16, 2015 12:54
Extra stuff to make WP more manageable
// Skips the FTP details
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}
@amertkara
amertkara / django_manage_script.py
Last active August 29, 2015 14:15
Script with headers required to run like django manage.py
import sys
import os
sys.path.append('path/to/django/project/root')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.conf import settings
@amertkara
amertkara / aws_utils.py
Last active March 13, 2024 11:10
Amazon SNS Notification Verification with Python, M2Crypto. When the SNS pushes a notification, a receiver should verify the origin/integrity of the push notification (AWS) using the signature and certificate provided in the notification data. The function `verify_sns_notification` below takes the request object and verifies the origin/integrity…
# -*- coding: utf-8 -*-
import json
import urllib2
from M2Crypto import X509
from base64 import b64decode
from M2Crypto.Err import M2CryptoError
SNS_MESSAGE_TYPE_SUB_NOTIFICATION = "SubscriptionConfirmation"
SNS_MESSAGE_TYPE_NOTIFICATION = "Notification"
SNS_MESSAGE_TYPE_UNSUB_NOTIFICATION = "UnsubscribeConfirmation"
def get_week_day(week_year, week_number, week_day=0):
""" For a given year and week_number, gets the day of that particular week
If week_year is 2014, week_number is 14 and week_day = 0,
it returns datetime.datetime(2014, 4, 6, 0, 0)
Args:
week_year (int)
week_number (int)
week_day (int): default is Sunday (0)
@amertkara
amertkara / gist:8177991
Last active January 1, 2016 17:29
Adding a new category to Joomla (Tested on 3.2) some of the category parameters are dependent on your situation so edit them according to your case (i.e. tag IDs might be different in your database)
<?php
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(__FILE__)));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
jimport('joomla.application.component.model');