Function:
function shorten_text($text, $max_length = 140, $cut_off = '...', $keep_word = false)
{
if(strlen($text) <= $max_length) {
return $text;
}
if(strlen($text) > $max_length) {
SELECT | |
CONCAT_WS( | |
'\n', | |
'namespace App\\Entity;', | |
'\n', | |
CONCAT( | |
'class ', | |
CONCAT(UCASE(SUBSTRING(s.table_name, 1, 1)), LOWER(SUBSTRING(s.table_name, 2))), | |
' {' | |
), |
<?php | |
$targetDir = '../public/'; | |
$output = "<?php\n"; | |
$output .= "namespace App\Controller\n\n"; | |
$output .= "#[Route('/')]\n"; | |
$output .= "class NewClass() extends AbstractController {\n"; | |
$files = scandir($targetDir); | |
foreach ($files as $file) { | |
echo "Reading File: " . $targetDir . $file . "\n"; | |
if (is_file($targetDir . $file)) { |
USE [HobbyDB] | |
GO | |
/****** Object: Table [dbo].[AspNetRoleClaims] Script Date: 6/4/2018 10:18:03 PM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetRoleClaims]') AND type in (N'U')) | |
BEGIN | |
CREATE TABLE [dbo].[AspNetRoleClaims]( |
Function:
function shorten_text($text, $max_length = 140, $cut_off = '...', $keep_word = false)
{
if(strlen($text) <= $max_length) {
return $text;
}
if(strlen($text) > $max_length) {
<?php | |
/* | |
Second Assignment | |
Write a script, module, application or program in PHP, which upon execution accepts | |
two arguments. One of those arguments should be a "total cost" (in dollars and/or cents) | |
and the other an "amount | |
provided" (also in dollars and/or cents). Return as output the change that should be | |
provided, by returning the count of each denomination of bills and/or coins. Extra | |
points for object oriented and/or advanced concepts. |
DROP FUNCTION IF EXISTS proper; | |
SET GLOBAL log_bin_trust_function_creators=TRUE; | |
DELIMITER | | |
CREATE FUNCTION proper( str VARCHAR(128) ) | |
RETURNS VARCHAR(128) | |
BEGIN | |
DECLARE c CHAR(1); | |
DECLARE s VARCHAR(128); | |
DECLARE i INT DEFAULT 1; | |
DECLARE bool INT DEFAULT 1; |
#!/usr/bin/env python | |
## Mysql-Python basic examples. | |
## All code is taken from [here](http://zetcode.com/databases/mysqlpythontutorial/) | |
## Gist created only for quick reference purpose | |
import sys | |
import _mysql | |
import MySQLdb as mdb |
<?php | |
/** | |
* Generates getter and setter methods for a PHP class | |
* @author Michael Angstadt | |
*/ | |
class GetterSetterGen{ | |
/** | |
* The source code of the PHP class. | |
* @var string | |
*/ |
SELECT CONCAT(column_name, ': ', (CASE data_type WHEN 'bigint' THEN 'number' WHEN 'smallint' THEN 'number' WHEN 'char' THEN 'string' WHEN 'tinyint' THEN 'number' WHEN 'int' THEN 'number' WHEN 'varchar' THEN 'string' WHEN 'text' THEN 'string' WHEN 'timestamp' THEN 'string' WHEN 'date' THEN 'string' WHEN 'datetime' THEN 'string' WHEN 'decimal' THEN 'number' END), ';') | |
FROM information_schema.columns | |
WHERE table_name = '{tablename}' AND table_schema = '{database}' |
<?php | |
class primeTest | |
{ | |
private $primeArray; | |
public function __construct() { | |
$this->primeArray = array(); | |
} | |
private function isPrime($n) { |