Skip to content

Instantly share code, notes, and snippets.

View smddzcy's full-sized avatar

Samed Düzçay smddzcy

View GitHub Profile
@smddzcy
smddzcy / regexp_last30days_oneliner.php
Last active October 1, 2015 09:27
One line regExp date builder for last 30 days in PHP. Doesn't match dates with ':' delimiter; since they are obviously "hours", not "dates" ._.
$regexpLastThirty = '#' . '(' .
/*
* regExp builder for this month
* d-m-Y m-d-Y Y-d-m Y-m-d
* d-m-y m-d-y y-d-m y-m-d
*/
implode('|', array_map(function ($v) {
return
'(' . str_pad($v, 2, 0, STR_PAD_LEFT) . '[^:]?' . str_pad(date('m'), 2, 0, STR_PAD_LEFT) . '[^:]?' . date('Y') . ')'
. '|' . '(' . str_pad(date('m'), 2, 0, STR_PAD_LEFT) . '[^:]?' . str_pad($v, 2, 0, STR_PAD_LEFT) . '[^:]?' . date('Y') . ')'
@smddzcy
smddzcy / _exec.php
Created October 4, 2015 14:59
System command execute function, tries a bunch of funcs
/**
* @param string $cmd Command to execute
* @return string Result
*/
public function _exec($cmd)
{
$res = '';
if (!empty($cmd)) {
if (@function_exists('exec')) {
exec($cmd, $res);
@smddzcy
smddzcy / disableLogs-linux.sh
Created October 26, 2015 21:23
Delete & disable logs on Linux
#!/bin/bash
#delete bash logs & disable logging on linux
export HISTFILE=/dev/null;
export HISTSIZE=0;
rm ~/.bash_history -rf;
history -c;
@smddzcy
smddzcy / .htmlhintrc
Created June 12, 2016 14:16 — forked from DrummerHead/.htmlhintrc
HTMLHint rules
{
"tagname-lowercase": true,
"attr-lowercase": true,
"attr-value-double-quotes": true,
"attr-value-not-empty": true,
"attr-no-duplication": true,
"doctype-first": false,
"tag-pair": true,
"tag-self-close": false,
"spec-char-escape": true,
objToFormData = (obj, formData, prefix) ->
formData ?= new FormData
formKey = null
angular.forEach obj, (val, key) ->
if prefix?
formKey = "#{prefix}[#{key}]"
else
formKey = key
@smddzcy
smddzcy / Solution.java
Created October 8, 2016 21:33
Very simple Graph implementation in Java
private static class Vertex {
private int uniqueLabel;
public Vertex(int uniqueLabel) {
super();
this.uniqueLabel = uniqueLabel;
}
@Override
public boolean equals(Object obj) {
@smddzcy
smddzcy / elixirphoenix.bash
Last active February 1, 2017 09:36 — forked from likethesky/elixirphoenix.bash
Installing Elixir & the Phoenix framework with Homebrew on OS X
brew update && brew doctor # Repeat, until you've done *all* the Dr. has ordered!
brew install postgresql # You'll need postgres to do this... you may also need to 'initdb' as well. Google it.
brew install elixir
mix local.hex
createuser -d postgres # create the default 'postgres' user that Chris McCord seems to like -- I don't create mine w/a pw...
# Install the latest Phoenix. It will give us the command `mix phoenix.new`
mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import Loading from '../Loading';
export default class Image extends PureComponent {
static loadedSrcs = new Set();
constructor(props, context) {
super(props, context);
this.state = { isLoaded: false, isLoading: false, error: null };
import React from 'react';
import PropTypes from 'prop-types';
function Loading({ size, fullScreen, isGold }) {
const style = {
borderWidth: `${size / 10}px`,
width: `${size}px`,
height: `${size}px`,
};
if (fullScreen) {
@smddzcy
smddzcy / react-loading.js
Created November 1, 2018 10:32
A basic loading indicator
import React from 'react';
import PropTypes from 'prop-types';
function Loading({ size, fullScreen, isGold }) {
const style = {
borderWidth: `${size / 10}px`,
width: `${size}px`,
height: `${size}px`,
};
if (fullScreen) {