- 1
- 2
- 3
def gsubn text
text.gsub('\n','').gsub('\t','').gsub('\r','').gsub(/\"/,'').gsub('@@@@','. ').gsub(" "," ")
end
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
def gsubn text
text.gsub('\n','').gsub('\t','').gsub('\r','').gsub(/\"/,'').gsub('@@@@','. ').gsub(" "," ")
end
последний gsub меняет два пробела на один
0
Тем временем, в Яунде двадцать четыре градуса тепла.
+4
def do_creaprim(self, mesh, objname, addondir):
global message
objname = objname.replace(".", "")
objname = objname.replace(" ", "_")
bm = bmesh.new()
bm.from_mesh(mesh)
try:
txt = bpy.data.texts[str.lower("add_mesh_" + objname) + ".py"]
txt.clear()
except:
txt = bpy.data.texts.new("add_mesh_" + str.lower(objname) + ".py")
strlist = []
strlist.append("bl_info = {\n")
strlist.append("\"name\": \"" + objname + "\", \n")
strlist.append("\"author\": \"Gert De Roost\",\n")
strlist.append("\"version\": (1, 0, 0),\n")
strlist.append("\"blender\": (2, 65, 0),\n")
strlist.append("\"location\": \"Add > Mesh\",\n")
strlist.append("\"description\": \"Create " + objname + " primitive.\",\n")
strlist.append("\"warning\": \"\",\n")
strlist.append("\"wiki_url\": \"\",\n")
strlist.append("\"tracker_url\": \"\",\n")
strlist.append("\"category\": \"Add Mesh\"}\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("if \"bpy\" in locals():\n")
strlist.append(" import imp\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("import bpy\n")
strlist.append("import bmesh\n")
strlist.append("import math\n")
strlist.append("from mathutils import *\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("\n")
strlist.append("class " + objname + "(bpy.types.Operator):\n")
strlist.append(" bl_idname = \"mesh." + str.lower(objname) + "\"\n")
strlist.append(" bl_label = \"" + objname + "\"\n")
strlist.append(" bl_options = {\'REGISTER\', \'UNDO\'}\n")
strlist.append(" bl_description = \"add " + objname + " primitive\"\n")
strlist.append("\n")
strlist.append(" def invoke(self, context, event):\n")
strlist.append("\n")
strlist.append(" mesh = bpy.data.meshes.new(name=\"" + objname + "\")\n")
strlist.append(" obj = bpy.data.objects.new(name=\"" + objname + "\", object_data=mesh)\n")
strlist.append(" scene = bpy.context.scene\n")
strlist.append(" scene.objects.link(obj)\n")
strlist.append(" obj.location = scene.cursor_location\n")
strlist.append(" bm = bmesh.new()\n")
strlist.append(" bm.from_mesh(mesh)\n")
strlist.append("\n")
strlist.append(" idxlist = []\n")
posn = 0
strlist.append(" vertlist = [")
for v in bm.verts:
if posn > 0:
strlist.append(", ")
posn += 1
strlist.append(str(v.co[:]))
strlist.append("]\n")
strlist.append(" for co in vertlist:\n")
strlist.append(" v = bm.verts.new(co)\n")
strlist.append(" bm.verts.index_update()\n")
strlist.append(" idxlist.append(v.index)\n")
posn = 0
strlist.append(" edgelist = [")
for e in bm.edges:
if posn > 0:
strlist.append(", ")
posn += 1
strlist.append("[" + str(e.verts[0].index) + ", " + str(e.verts[1].index) + "]")
strlist.append("]\n")
strlist.append(" for verts in edgelist:\n")
strlist.append(" try:\n")
strlist.append(" bm.edges.new((bm.verts[verts[0]], bm.verts[verts[1]]))\n")
strlist.append(" except:\n")
strlist.append(" pass\n")
posn1 = 0
strlist.append(" facelist = [(")
for f in bm.faces:
if posn1 > 0:
strlist.append(", (")
posn1 += 1
posn2 = 0
for v in f.verts:
if posn2 > 0:
strlist.append(", ")
strlist.append(str(v.index))
posn2 += 1
strlist.append(")")
strlist.append("]\n")
strlist.append(" bm.verts.ensure_lookup_table()\n")
strlist.append(" for verts in facelist:\n")
Залил вам отборного
0
create or replace function TO_NUMBER_EX (sNumber in varchar2) return number is
---------------------------------------------------------------------
-- Преобразование строки в число с разными символами разделителями
---------------------------------------------------------------------
iRet number(12,3) :=0;
cReplSgn char(1);
cToReplSgn char(1);
begin
begin
iRet := to_number(sNumber);
exception
when OTHERS then
iRet := null;
end;
if iRet is null then
begin
if instr(sNumber,'.') > 0 then
cReplSgn := '.';
cToReplSgn := ',';
else
cReplSgn := ',';
cToReplSgn := '.';
end if;
iRet := to_number(replace(sNumber,cReplSgn,cToReplSgn));
exception
when OTHERS then
iRet := null;
end;
end if;
return(nvl(iRet,0));
end TO_NUMBER_EX;
PL/SQL
велосипедно-костыльное программирование с неожиданными значениями по умолчанию
0
#include <iostream>
#include <string>
int main()
{
std::cout << "Купи слона!" << std::endl;
while(true)
{
std::string temp;
std::getline(std::cin, temp);
std::printf("Все говорят: \"%s\", а ты купи слона!\n", temp.c_str());
}
}
Когда не любишь 1c.
0
public bool isUnderpayment(double paymentValue)
{
if (paymentValue > 0)
return true;
return false;
}
Пятница, смеркалось.
−1
[color=green][s][u][b][size=20]ДАВАЙТЕ ФЛУДИТЬ И ТРОЛЛИТЬ[/size][/color][/b][/u][/s]
ДАВАЙТЕ ФЛУДИТЬ И ТРОЛЛИТЬ
−1
TServerThread = class(TThread)
private
procedure DoReadData;
protected
ThreadOwner: TIPCServer;
procedure Execute; override;
constructor Create(AThreadOwner: TIPCServer);
destructor Destroy; override;
public
end;
Мы кодили, кодили и наконец накодили!
0
<!DOCTYPE html>
<html>
<head>
<?php
$filename = 'mes.txt';
$count = "count.txt";
$count_file = fopen($count, "r");
$handle = fopen($filename, "rb");
date_default_timezone_set('Europe/Moscow');
$contents = file_get_contents($filename);
$contents2=nl2br($contents);
$password=htmlspecialchars($_POST["pass"]);
if($password=='dfhsdhf' || $password=='eeeeeer')
{
}
else
{
echo '403';
exit;
}
if( isset( $_POST['obn'] ) )
{
fclose($count_file);
$count_file = fopen($count, "w");
fwrite($count_file, '0');
echo "Обнулено";
$date = date("Y-m-d H:i:s");
$date_file = fopen("date.txt", "w");
fwrite($date_file, "$date");
}
?>
<title>Admin panel</title>
</head>
<body>
<h1>Начиная с <div id=date><?php echo file_get_contents("date.txt") ?></div> сайте было <div id=count><?php echo file_get_contents("count.txt") ?></div> людей</h1>
<p><?php if ($password == 'dfhsdhf')
echo "$contents2";
?>
</p>
<br>
<?php if ($password != 'dfhsdhf')
exit;
?>
<form method="POST">
<p>Введите код подтверждения</p>
<input type="password" name="pass">
<input type="submit" name="obn" value="Обнулить" />
</form>
</body>
</html>
Лучшая админка на php
+2
if hasattr(query, "items"):
query = query.items()
else:
# It's a bother at times that strings and string-like objects are
# sequences.
try:
# non-sequence items should not work with len()
# non-empty strings will fail this
if len(query) and not isinstance(query[0], tuple):
raise TypeError
# Zero-length sequences of all types will get here and succeed,
# but that's a minor nit. Since the original implementation
# allowed empty dicts that type of behavior probably should be
# preserved for consistency
except TypeError:
ty, va, tb = sys.exc_info()
raise TypeError("not a valid non-string sequence "
"or mapping object").with_traceback(tb)
https://github.com/python/cpython/blob/master/Lib/urllib/parse.py#L848
Зачем генерировать TypeError, а потом ее ловить и снова кидать?