Skip to content

Instantly share code, notes, and snippets.

public static class HtmlTruncator
{
public static string LimitOnWordBoundary(string str, int maxLength, string ellipses = "...")
{
XmlDocument doc = new XmlDocument();
XmlParserContext context = new XmlParserContext(doc.NameTable, new XmlNamespaceManager(doc.NameTable), null, XmlSpace.Preserve);
XmlTextReader reader = new XmlTextReader("<xml>" + str + "</xml>", XmlNodeType.Document, context);
bool shouldWriteEllipses;
@cloudcreatordotio
cloudcreatordotio / ImageUtil.cs
Created April 19, 2024 11:59 — forked from gsscoder/ImageUtil.cs
C# image utilities
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
public static class ImageUtil
{
public static Image Resize(this Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
@cloudcreatordotio
cloudcreatordotio / index.html
Created July 24, 2022 04:16 — forked from oliveratgithub/index.html
Simple, quick & standalone HTML5 responsive placeholder Website. Runs by simply copy-paste the whole code without any additional resource files. It's based on PureCSS.io with jQuery containing a fullstretch-background image plugin and a date-time countdown; kudos to unsplash.it for beautiful placeholder images.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Dummy Page</title>
<meta name="description" content="Simple, quick, standalone responsive placeholder Website without any additional resources">
<meta name="author" content="https://gist.github.com/oliveratgithub">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css" integrity="sha384-nn4HPE8lTHyVtfCBi5yW9d20FjT8BJwUXyWZT9InLYax14RDjBj46LmSztkmNP9w" crossorigin="anonymous">
<!--[if lt IE 9]>
@cloudcreatordotio
cloudcreatordotio / function.php
Created May 30, 2020 15:39 — forked from hlashbrooke/function.php
WordPress: Check if user role exists
function role_exists( $role ) {
if( ! empty( $role ) ) {
return $GLOBALS['wp_roles']->is_role( $role );
}
return false;
}
@cloudcreatordotio
cloudcreatordotio / splat.rb
Created February 19, 2020 02:00 — forked from earlonrails/splat.rb
Iterm function which will create multiple tabs in a grid or vertical panes and execute the command or commands passed to it. ie. splat "ping google.com" "ping cnn.com" "ping twitter.com" "ping yahoo.com"
#!/usr/local/bin/ruby
require 'shellwords'
args = ARGV
size = args.size
tab_open = 'tell i term application "System Events" to keystroke "t" using {command down}'
v_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down}'
h_pane_open = 'tell i term application "System Events" to keystroke "d" using {command down, shift down}'
go_left_one_pane = 'tell i term application "System Events" to key code 123 using {command down, option down}'
script_builder = Proc.new do |tell, command|
@cloudcreatordotio
cloudcreatordotio / php-pools.md
Created November 18, 2019 22:12 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@cloudcreatordotio
cloudcreatordotio / Script.sql
Created November 10, 2019 22:13 — forked from amr-swalha/Script.sql
Script for Database for ASP.NET Core Course
/****** Object: Table [dbo].[Customer] Script Date: 5/20/2018 10:26:06 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customer](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NULL,
[Email] [nvarchar](200) NULL,
[Phone] [nvarchar](200) NULL,
USE [master]
GO
/****** Object: Database [DapperExample] Script Date: 3/08/2019 3:26:01 PM ******/
CREATE DATABASE [DapperExample]
GO
USE [DapperExample]
GO
/****** Object: Table [dbo].[Event] Script Date: 3/08/2019 3:26:01 PM ******/
SET ANSI_NULLS ON
GO
@cloudcreatordotio
cloudcreatordotio / phpstorm.txt
Created August 21, 2019 20:37 — forked from tvlooy/phpstorm.txt
PhpStorm cheat sheet
ctrl + alt + shift + t = refactor this
alt + enter = allerlei shortcuts
ctrl + alt + l = reformat code
shift + f11 = show bookmarks
f11 = insert bookmark
alt + insert = file new
ctrl + n = navigate class
ctrl + shift + n = navigate file
ctrl + shift + f = find in path
ctrl + alt + shift + insert = commit file (eigen shortcut)
@cloudcreatordotio
cloudcreatordotio / example.com.conf
Created March 26, 2019 02:02 — forked from a-vasyliev/example.com.conf
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key