$("#search-submit").click(function() {
$("#search form").submit()
});
type="submit"
is too mainstream, jquery is the proper way to do it
if yearOfBirth > 2002 {
fmt.Errorf("year of birth not allowed %d", yob)
return
}
string month = DateTime.Today.Month.ToString();
if (DateTime.Today.Month < 10)
{
month = "0" + month;
}
string day = DateTime.Today.Day.ToString();
if (DateTime.Today.Day < 10)
{
day = "0" + day;
}
string dateCorrect = String.Format("{0}.{1}.{2}", DateTime.Today.Year, month, day);
string dateDue = "";
if (transferFields.DueDate.SelectedDate.HasValue)
{
var dateDuearr = transferFields.DueDate.Value.Split(' ')[0].Split('.');
dateDue = dateDuearr[2] + '.' + dateDuearr[1] + '.' + dateDuearr[0];
}
else {
dateDue = dateCorrect;
}
Real developers don't use built in parsing and formatting methods.
from django.http import JsonResponse, HttpResponse
import requests
def download_custom_award(request):
try:
custom_img = requests.get(request.GET.get('award'))
response = HttpResponse(custom_img.content, content_type='application/PNG')
filename = "Your_Award.png"
response['Content-Disposition'] = 'attachment; filename=%s' % (filename)
return response
except Exception as e:
return JsonResponse({'Status': 404, "message": e.message})
This developer was trying to force the browser to download a custom image rather than show it inline, so he coded an open reverse proxy and attempted to release it to a production web app. Also, all exceptions are trapped and shown to the user in plaintext in their browser.
int true = 0;
while (true)
{
//do something
}
true = false
function add(input1,input2) {
var number1 = input1.toString();
var number2 = input2.toString();
var numbers1 = new Array();
var numbers2 = new Array();
var size1 = 0;
var size2 = 0;
while(size1 < number1.length) {
var SizeAndNumberToAddToNumbers1Array = 0;
var Number1FromFunctionAddLength = number1.length-size1-1;
SizeAndNumberToAddToNumbers1Array = number1.charAt(size1);
while(Number1FromFunctionAddLength > 0){
SizeAndNumberToAddToNumbers1Array = SizeAndNumberToAddToNumbers1Array + "0";
Number1FromFunctionAddLength = Number1FromFunctionAddLength-1;
}
numbers1.push(SizeAndNumberToAddToNumbers1Array);
size1 = size1 + 1;
}
while(size2 < number2.length) {
var SizeAndNumberToAddToNumbers1Array2 = 0;
var Number1FromFunctionAddLength2 = number2.length-size2-1;
SizeAndNumberToAddToNumbers1Array2 = number2.charAt(size2);
while(Number1FromFunctionAddLength2 > 0){
SizeAndNumberToAddToNumbers1Array2 = SizeAndNumberToAddToNumbers1Array2 + "0";
Number1FromFunctionAddLength2 = Number1FromFunctionAddLength2-1;
}
numbers2.push(SizeAndNumberToAddToNumbers1Array2);
size2 = size2 + 1;
}
var result1 = 0;
var saize1 = 0;
while(saize1 < numbers1.length){
var topush1 = numbers1[saize1];
result1=result1+parseInt(topush1);
saize1 = saize1 + 1;
}
var result2 = 0;
var saize2 = 0;
while(saize2 < numbers2.length){
var topush2 = numbers2[saize2];
result2=result2+parseInt(topush2);
saize2 = saize2 + 1;
}
return result1+result2;
}
advanced and optimized add function better than a + b
Native XML structure:
<?xml version="1.0" encoding="utf-8" ?>
<tree>
<node name="root">
<node name="TELEVISIONS">
<node name="TUBE"/>
<node name="LCD"/>
<node name="PLASMA"/>
</node>
<node name="PORTABLE ELECTRONICS">
<node name="MP3 PLAYERS">
<node name="FLASH"/>
</node>
<node name="CD PLAYERS"/>
<node name="2 WAY RADIOS"/>
</node>
</node>
</tree>
Flattened XML structure (example 1):
<tree>
<node key="0">root</node>
<node key="1" parent="0">TELEVISIONS</node>
<node key="2" parent="1">TUBE</node>
<node key="3" parent="1">LCD</node>
<node key="4" parent="1">PLASMA</node>
<node key="5" parent="0">PORTABLE ELECTRONICS</node>
<node key="6" parent="5">MP3 PLAYERS</node>
<node key="7" parent="6">FLASH</node>
<node key="8" parent="5">CD PLAYERS</node>
<node key="9" parent="5">2 WAY RADIOS</node>
</tree>
Flattened XML structure (example 2):
<tree>
<node>
<name>root</name>
<depth>0</depth>
</node>
<node>
<name>TELEVISIONS</name>
<depth>1</depth>
</node>
<node>
<name>TUBE</name>
<depth>2</depth>
</node>
<node>
<name>LCD</name>
<depth>2</depth>
</node>
<node>
<name>PLASMA</name>
<depth>2</depth>
</node>
<node>
<name>PORTABLE ELECTRONICS</name>
<depth>1</depth>
</node>
<node>
<name>MP3 PLAYERS</name>
<depth>2</depth>
</node>
<node>
<name>FLASH</name>
<depth>3</depth>
</node>
<node>
<name>CD PLAYERS</name>
<depth>2</depth>
</node>
<node>
<name>2 WAY RADIOS</name>
<depth>2</depth>
</node>
</tree>
def get_verified_infos(request):
try:
# request logic here
return data
except Exception:
logger.error(
'Request to XXX was unsuccessful, '
'Will retry till max recursion! Retrying...'
)
return get_verified_infos(request)
Used for OpenID authentication
ngOnInit() {
this._FunctionService.getSicksList().then(res => {
let resf:any = res;
if (resf.err) {
} else {
this.diagnosticAll = resf.data
}
}, err => { })
}
/*
ngOnInit() {
this._FunctionService.getSicksList().then(res => {
this.diagnosticAll = res.data
}, err => { })
}
*/
<?php
if(!defined('WPINC')) // MUST have WordPress.
exit ('Do not access this file directly.');
if(!class_exists('pluginName_options_page_class'))
{
/**
* Menu page blah
*
* @package blah
* @since 140617
*/
class pluginName_options_page_class
{
public function __construct()
{
echo '<div class="wrap menu-page">'."\n";
echo '<div class="wp-header-end"></div>'."\n";
echo '<div class="menu-page-toolbox">'."\n";
pluginName_some_other_class::display();
echo '</div>'."\n";
echo '<h2>Options</h2>'."\n";
echo '<table class="menu-page-table">'."\n";
echo '<tbody class="menu-page-table-tbody">'."\n";
echo '<tr class="menu-page-table-tr">'."\n";
echo '<td class="menu-page-table-l">'."\n";
echo '<form method="post" name="plugin_options_form" id="plugin--options-form" autocomplete="off">'."\n";
echo '<input type="hidden" name="plugin_options_save" id="plugin--options-save" value="'.esc_attr(wp_create_nonce('plugin--options-save')).'" />'."\n";
echo '<div class="menu-page-group" title="Account Details">'."\n";
/* includes things like this gem */
echo (!is_multisite() || !pluginName_utils_conds::is_multisite_farm() || is_main_site()) ? '<p>[ Really Long message about something ]</p>'."\n" : '';
/* ... continues until end ... */
echo '</div>'."\n";
}
}
}
new pluginName_options_page_class ();
The entire file is a single class with a constructor. The constructor is ~ 1150 lines of echo statements with a few PHP conditionals thrown in. There are no other methods. The class is instantiated as soon as it is defined. Clever...
j =0
import random
import hashlib
#geetting inputs
c = input("data ")
n= int(input("N(the count of last numbers)= "))
v= input(str(n)+" last char ")
#list of alphas
l1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', 'u']
l2 = ["A", 'B', 'C', 'D', 'E', 'F','G' , 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', 'U']
alphas= 0
#calc the count of alppphas
x=""
for j in c:
if(j in l1 or j in l2):
alphas +=1
#positions
h = 2**alphas
hs = []
cc =0
j=0
xf =0
# the stat of main coode
for j in range(h):
#making a sring with 1 and 0
while True:
x=""
for i in range(len(c)):
x+=str(random.randint(0,1))
if(not(x in hs)):
hs.append(x)
break
Xx =""
cc =0
#convert that to lower and upper
for j1 in x:
if(j1=="0"):
Xx+=c[cc].lower()
else:
Xx+=c[cc].upper()
cc+=1
#hash
m = hashlib.sha256()
m.update(Xx.encode('utf-8'))
h = m.hexdigest()
#if
if(h[0-n:]==v):
print("text :"+Xx)
print("hash :"+h)
xf = True
break
if xf==True:
break
j =0
#if that not possible to have git push -Desirable-hash by changed lower to upper and upper to lower
if(xf==0):
while 1:
j+=1
d = c+str(j)
m = hashlib.sha256()
m.update(d.encode('utf-8'))
h = m.hexdigest()
if(h[0-n:]==v):
print("text :"+d)
print("hash :"+h)
break
x = input("press enter to exit")0
this program take a string from you and give you a Desirable-hash by changing lower to upper and changing lower to upper if that possible
Public Shared Function CompeleteDateStr(DateStr As String) As String
'MBS 96-09-25: High Caliber DataEntry
Dim DateVal = CType(DateStr, Integer)
If DateVal < 1 Then Return ""
If DateVal < maxDay Then 'DayOnly
Return MakeJalaliDate(curYear, curMonth, DateVal, _4DigitYear)
ElseIf DateVal > maxDay Then
Dim YearPiece? As Short = Nothing, MonthPiece? As Byte = Nothing, DayPiece As Byte
Select Case DateVal
Case Is < 100
MonthPiece = (DateVal \ 10) Mod 10
DayPiece = DateVal Mod 10
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
Case Is < 1000
MonthPiece = DateVal \ 10
DayPiece = DateVal Mod 10
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
MonthPiece = (DateVal \ 100) Mod 10
DayPiece = DateVal Mod 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
DayPiece = DateVal \ 10
MonthPiece = DateVal Mod 10
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
DayPiece = (DateVal \ 100) Mod 10
MonthPiece = DateVal Mod 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
Case Is < 10000
MonthPiece = DateVal \ 100
DayPiece = DateVal Mod 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
MonthPiece = DateVal Mod 100
DayPiece = DateVal \ 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
DayPiece = DateVal \ 100
MonthPiece = DateVal Mod 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
DayPiece = DateVal Mod 100
MonthPiece = DateVal \ 100
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, curYear) Then Return MakeJalaliDate(curYear, MonthPiece, DayPiece, _4DigitYear)
MonthPiece = (DateVal \ 10) Mod 10
YearPiece = DateVal \ 100
If IsValidMonth(MonthPiece) Then
DayPiece = DateVal Mod 10
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
Else
MonthPiece = (DateVal \ 100) Mod 10
YearPiece = DateVal Mod 100
DayPiece = DateVal \ 1000
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
End If
Case Is < 100000
Dim DaySize As Byte = 2
MonthPiece = (DateVal Mod 1000) \ 10
If Not IsValidMonth(MonthPiece) Then
MonthPiece = (DateVal \ 100) Mod 10
DaySize = 1
If Not IsValidMonth(MonthPiece) Then Return ""
End If
YearPiece = DateVal \ 1000
DayPiece = DateVal Mod 10 ^ DaySize
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece)
YearPiece = DateVal Mod 100
DayPiece = DateVal \ (10000 \ (10 ^ DaySize))
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece)
Case Is < 1000000
MonthPiece = (DateVal Mod 10000) \ 100
If IsValidMonth(MonthPiece) Then
YearPiece = DateVal \ 10000
DayPiece = DateVal Mod 100
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
YearPiece = DateVal Mod 100
DayPiece = DateVal \ 10000
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
End If
YearPiece = DateVal \ 100
If YearPiece > 1300 AndAlso YearPiece < 1500 Then
MonthPiece = (DateVal \ 10) Mod 10
DayPiece = DateVal Mod 10
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
End If
YearPiece = DateVal Mod 10000
If YearPiece > 1300 AndAlso YearPiece < 1400 Then
DayPiece = DateVal \ 100000
MonthPiece = (DateVal \ 10000) Mod 10
If IsValidMonth(MonthPiece) AndAlso IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece + If(_4DigitYear, 0, -1300), MonthPiece, DayPiece, _4DigitYear)
End If
Case Is < 10000000
Dim DaySize As Byte = 2
MonthPiece = (DateVal Mod 1000) \ 10
If Not IsValidMonth(MonthPiece) Then
MonthPiece = (DateVal \ 100) Mod 10
DaySize = 2
If Not IsValidMonth(MonthPiece) Then Return ""
End If
YearPiece = DateVal \ 1000
DayPiece = DateVal Mod 10 ^ DaySize
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece)
YearPiece = DateVal Mod 10000
DayPiece = DateVal \ (100000 * (10 ^ DaySize))
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece)
Case Is < 100000000
MonthPiece = (DateVal Mod 10000) \ 100 '13961229
If IsValidMonth(MonthPiece) Then
YearPiece = DateVal \ 10000
DayPiece = DateVal Mod 100
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
YearPiece = DateVal Mod 10000
DayPiece = DateVal \ 1000000
If IsValidDay(DayPiece, MonthPiece, YearPiece) Then Return MakeJalaliDate(YearPiece, MonthPiece, DayPiece, _4DigitYear)
End If
End Select
Return ""
End If
End Function
this code is so wrong in so many different levels
typedef NS_ENUM(NSUInteger, MyEnum1) {
PackagesNo1 = 1,
PackagesNo2 = 2,
PackagesNo4 = 4,
PackagesNo8 = 8
};
typedef NS_ENUM(NSUInteger, MyEnum2) {
LEVEL0 = 0,
LEVEL1 = 1,
LEVEL2 = 2,
LEVEL3 = 3
};
- (int)packagesNeededForLevel:(int)level {
switch (level) {
case LEVEL0:
return PackagesNo8;
case LEVEL1:
return PackagesNo4;
case LEVEL2:
return PackagesNo2;
case LEVEL3:
return PackagesNo1;
}
}
well done mr junior
var state = getCookie("state");
function checkCookie(args) {
if (state == args) {
return true;
} else {
alert("Request denied. Invalid auth code provided.");
return false;
}
}
const tokenElement = document.getElementsByName("dream");
var loginSrv = checkCookie(getAllUrlParams().state);
document.cookie = `state=${getAllUrlParams().state}; path=/`;
tokenElement.innerText = getAllUrlParams().code;
if (getAllUrlParams().state != loginSrv) {
alert(`Incorrect auth code provided. The correct code is ${state}`);
}
If they provide the wrong oauth state code, tell the user the correct one!
if((strtotime(date("Y-m-d"))-strtotime(date("Y-m-d", filemtime($filename))))/(3600)<=$config->hourDiff) return true; else return false;
please notice the brackets around 3600