This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Here's some sample code based on the book Learning Python by Mark Lutz that addresses your question: | |
import sys | |
temp = sys.stdout # store original stdout object for later | |
sys.stdout = open('log.txt', 'w') # redirect all prints to this log file | |
print("testing123") # nothing appears at interactive prompt | |
print("another line") # again nothing appears. it's written to log file instead | |
sys.stdout.close() # ordinary file object | |
sys.stdout = temp # restore print commands to interactive prompt | |
print("back to normal") # this shows up in the interactive prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://joomla.stackexchange.com/questions/1054/displaying-a-joomla-module-using-php | |
$modules = JModuleHelper::getModules("dashboard_main"); | |
$document = JFactory::getDocument(); | |
$attribs = array(); | |
$attribs['style'] = 'xhtml'; | |
foreach ($modules as $mod) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PooledObjectPool { | |
private static long expTime = 6000;//6 seconds | |
public static HashMap<PooledObject, Long> available = new HashMap<PooledObject, Long>(); | |
public static HashMap<PooledObject, Long> inUse = new HashMap<PooledObject, Long>(); | |
public synchronized static PooledObject getObject() { | |
long now = System.currentTimeMillis(); | |
if (!available.isEmpty()) { | |
for (Map.Entry<PooledObject, Long> entry : available.entrySet()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################## | |
# Initialization # | |
################## | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get install curl | |
########## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Show template hierarchy and theme at the end of the request/page. | |
* @return void | |
*/ | |
function wpse31909_template_info() | |
{ | |
// Don't display for non-admin users | |
if ( ! current_user_can( 'manage_options' ) ) | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Desired=Unknown/Install/Remove/Purge/Hold | |
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend | |
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) | |
||/ Name Version Architecture Description | |
+++-===========================================================-===================================================-============-===================================================================================================================== | |
ii accountsservice 0.6.35-0ubuntu7.2 amd64 query and manipulate user account information | |
ii acl 2.2.52-1 amd64 Access control list utilities | |
ii acpi-support 0.142 amd64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// do pobrania z https://code.google.com/p/phpquery/ | |
// do pobrania z rashell.pl/clearsense/phpQuery-onefile.phps | |
require 'phpQuery-onefile.php'; | |
$server = 'http://rashell.pl'; | |
$results=array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g) { | |
document.write("<meta name='viewport' content='width=1165, user-scalable=no'>"); // or whichever meta tags make sense for your site | |
} else { | |
document.write("<meta name='viewport' content='width=max-device-width, user- scalable=no'>"); // again, which ever meta tags you need | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10:14 < krisd> mt3o: w python mozesz uzyc np. paramiko do laczenia sie przez ssh i wykonywania komend | |
10:15 <@samu> i socket może odpowiadać albo jsonem, albo picklem | |
10:17 <@samu> mt3o: $ echo '["--json", "www", "list"]' |nc -U /var/run/devil2.sock | |
10:17 < krisd> samu: masz jakies przyklady jak uzywac tego socketu? | |
10:17 <@samu> przykładów nie mam | |
10:17 <@samu> zwykłe połączenie z socketem na /var/run/devil2.sock | |
10:17 < mt3o> samu: to chyba wystarczy, thx :-) | |
10:17 < krisd> ok | |
10:17 <@samu> wysyłasz stringa, który jest prawidłową pythonową listą | |
10:17 <@samu> składającą się z tego, co byś wysyłał jako klient cli |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php foreach ([ | |
'http://fonts.googleapis.com/css?family=Alegreya+SC&subset=latin,latin-ext', | |
'http://fonts.googleapis.com/css?family=Lora&subset=latin,latin-ext', | |
'https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' | |
] as $font){ | |
?> | |
<link | |
rel="stylesheet" | |
href="<?=$font?>" |