Skip to content

Instantly share code, notes, and snippets.

View janoulle's full-sized avatar

Jane Ullah janoulle

View GitHub Profile
<?php
//http://stackoverflow.com/questions/470617/get-current-date-and-time-in-php
//code below is from stackoverflow
$now = new DateTime();
echo $now->format('Y-m-d H:i:s'); // MySQL datetime format
echo $now->getTimestamp(); // Unix Timestamp
$now = new DateTime(null, new DateTimeZone('America/New_York'));
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {
@janoulle
janoulle / kendoui-datasource-modified
Last active April 5, 2016 18:00
Modifying DataSourceResult in C#
public ActionResult Read([DataSourceRequest]DataSourceRequest, int item_id){
DataSourceResult audits = logs.ToDataSourceResult(request, audit => new AuditDTO{
id = audit.id
});
System.Collections.IEnumerable items = audits.Data;
@janoulle
janoulle / custom_command_kendoui_mvc
Last active August 29, 2015 14:02
KendoUI Custom Command MVC
columns.Command(
command.Custom("Remove").Click("removeForm").Text("Approve")
command.Custom("Approve").Click("approveForm").Text("Approve");
)
//removeForm and approveForm are JavaScript functions
<script type="text/javascript">
function removeForm(e){
e.preventDefault();
@janoulle
janoulle / AWS4Signer.groovy
Created September 30, 2017 04:05 — forked from devilelephant/AWS4Signer.groovy
Java/Groovy example of using Amazon AWS AWS4Signer class to sign requests (in our case elasticsearch calls)
package com.clario.aws
import com.amazonaws.DefaultRequest
import com.amazonaws.SignableRequest
import com.amazonaws.auth.AWS4Signer
import com.amazonaws.auth.AWSCredentialsProvider
import com.amazonaws.http.HttpMethodName
import groovy.util.logging.Slf4j
import org.apache.http.client.utils.URLEncodedUtils
import org.springframework.http.HttpHeaders

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

# https://g00glen00b.be/docker-spring-boot/
# Using the alpine image as a base​
FROM openjdk:8-jdk-alpine
# maintainer
MAINTAINER "Jane Doe <janedoe@gmail.com>"
# http://blog.zot24.com/tips-tricks-with-alpine-docker/ For keeping size small
RUN apk add --no-cache curl
//generates image like this: $project.group/applicationName:tagVersion
task image(type: Docker, dependsOn: build ) {
project.group = '' //this prevents the generated image from having the group value added. Personal preference to do this
applicationName = "yourapp"
dockerfile = file('Dockerfile')
tagVersion = 'latest'
doFirst {
copy {
from jar
into "${stageDir}/target"
sample docker-compose file
# Use postgres/example user/password credentials
version: '3.1'
networks:
myapp-network:
services:
=== Fetching app code failed
=!= Your app does not include a heroku.yml build manifest. To deploy your app, either create a heroku.yml: https://devcenter.heroku.com/articles/heroku-yml-build-manifest
Or change your stack by running: 'heroku stack:set heroku-16'