Skip to content

Instantly share code, notes, and snippets.

View fedir's full-sized avatar
🌤️
The sun is behind every cloud

Fedir RYKHTIK fedir

🌤️
The sun is behind every cloud
View GitHub Profile
@drewolson
drewolson / reflection.go
Last active November 21, 2024 15:11
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@hSATAC
hSATAC / gist:5343225
Created April 9, 2013 05:38
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@betweenbrain
betweenbrain / gist:5405671
Created April 17, 2013 16:26
Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed
<?php
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://blogs.guggenheim.org/map/feed/',
CURLOPT_USERAGENT => 'spider',
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
@ArtemGr
ArtemGr / example.sh
Last active April 10, 2023 18:59
Testing HTTP pipelining from the command line.
# http://aaronhawley.livejournal.com/12621.html
(echo -en "GET / HTTP/1.1\nHost: fropl.com\n\nGET / HTTP/1.1\nHost: fropl.com\n\n"; sleep 0.1) | telnet localhost 80
# Also:
perl -e '$| = 1; print "GET / HTTP/1.1\nHost: fropl.com\n\nGET / HTTP/1.1\nHost: fropl.com\n\n"; sleep (1)' | telnet localhost 80
# Also (from https://github.com/ellzey/libevhtp/issues/86#issuecomment-19137572):
(echo -en "GET /1 HTTP/1.1\r\n\r\nGET /2 HTTP/1.1\r\n\r\n"; sleep 0.1) | nc localhost 8081
@fedir
fedir / checkDatabaseTablesSize.sh
Last active February 22, 2018 18:24
Shows a dB tables size in MB #mysql #shell
#!/bin/sh
# shows a dB tables size in MB
# usage : checkDatabaseTablesSize.sh databasename
# mysql : SELECT TABLE_NAME,(DATA_LENGTH+INDEX_LENGTH)/1024/1024 FROM information_schema.TABLES WHERE table_schema="dbname";
DATABASE=$1
mysql -e "SELECT TABLE_NAME,(DATA_LENGTH+INDEX_LENGTH)/1024/1024 FROM information_schema.TABLES WHERE table_schema=\"${DATABASE}\";"
@benbalter
benbalter / gist.md
Last active May 24, 2025 09:51
Example of how to embed a Gist on GitHub Pages using Jekyll.

Here's an example of how to embed a Gist on GitHub Pages:

{% gist 5555251 %}

All you need to do is copy and paste the Gist's ID from the URL (here 5555251), and add it to a gist tag surrounded by {% and %}.

@maddy2101
maddy2101 / gist:5668835
Last active March 12, 2021 12:08
TCA, Model and Fluid Partial to display FAL images as a simple gallery using TYPO3 and Extbase 6.1
SQL:
images int(11) unsigned DEFAULT '0',
=======================================================
TCA
....
'images' => array(
'exclude' => 0,
'label' => 'images',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'images',
@fedir
fedir / getFilesDetailedStatisticsOrderingBySize.sh
Created May 31, 2013 09:54
Find files detailed statistics in shell : filesize, path, date of last access, date of last status change, date of last modification (in locale format; in unixstamp), ordering by size
#!/bin/bash
# ref. : man find
# printf options
# %p Files name.
# %P Files name with the name of the command line argument under which it was found removed.
# %s Files size in bytes.
# %Ak Files last access time in the format specified by k
# %Ck Files last status change time
# %Tk Files last modification time
# Time options k
@n1k0
n1k0 / private1.js
Last active December 19, 2015 13:49
Two alternatives to bring private methods to JavaScript. Prefer method 2.
(function(exports) {
function Universe() {
this.partialAnswer = 21;
}
exports.Universe = Universe;
// private methods
var privatePrototype = {
_computeAnswer: function() {
return this.partialAnswer * 2;
@fedir
fedir / fluidStandaloneView.php
Created July 15, 2013 16:08
Standalone views with Fluid with TYPO3 4.5.x LTS // via http://developpeurtypo3.wordpress.com/2011/03/03/fluid-sans-extbase/ * useful for hooks also, when we are working with non-extbase extensions
<?php
$template = t3lib_extMgm::extPath($this->extKey) . $this->conf['template'];
$view = t3lib_div::makeInstance('Tx_Fluid_View_StandaloneView');
$view->setTemplatePathAndFilename($template);
$view->assign('data', $this->data);
$view->render();