Fill assoc array with date - arrays

I need to fill a assoc array $pay_day with the key = date and a value of 0, from a start date $d1 till an end date $d2.
$d1 = strtotime("October 12 2014");
$d2 = strtotime("February 28 2015");
$startday = date('F j, Y', $d1 + (24 * 60 * 60));
echo "<h2>Startday is " . $startday . "</h2>";
$endday = date('F j, Y', $d2 + (24 * 60 * 60));
echo "<h2>Endday is " . $endday . "</h2>";
$n=0;
$d3=$d1;
while ($d3 <= $d2) {
$d3 = date('F j, Y', ($d1 + ++$n*(24 * 60 * 60)));
$pay_day[$d3] = 0;
}

$d1 = 'August 12 2014';
$d2 = 'February 28 2015';
$period = new \DatePeriod(
\DateTime::createFromFormat('F d Y', $d1),
new \DateInterval('P1D'),
\DateTime::createFromFormat('F d Y', $d2)->modify('+1 day'));
foreach($period as $date) {
$d3 = $date->format('F j, Y');
$pay_day[$d3] = 0;
}
print_r($pay_day);

Related

Inviter of undefined

It says no inviter as an error, and when I can't find the inviter, I want it to send a message saying he logged in with the Url or unknown. What should I do?Normal users do not have a problem when they come with an invitation, but they give such an error when they log in with the Url.
Error: (node:244) UnhandledPromiseRejectionWarning: TypeError: Cannot
read property 'in viter' of undefined
at C:\Users\Administrator\Desktop\1951 Moderation + Registrar + Stats\bot.js :276:63
const invites = {};
const wait = require("util").promisify(setTimeout);
client.on("ready", () => {
wait(1000);
client.guilds.cache.forEach(g => {
g.fetchInvites().then(guildInvites => {
invites[g.id] = guildInvites;
});
});
});
client.on("guildMemberAdd", member => {
member.setNickname("• İsim ' Yaş");
member.setNickname("• İsim ' Yaş");
member.roles.add(ayarlar.kayıtsızRol)
member.roles.add(ayarlar.kayıtsızRol)
if (member.user.bot) return;
member.guild.fetchInvites().then(async guildInvites => {
const ei = invites[member.guild.id];
invites[member.guild.id] = guildInvites;
const invite = await guildInvites.find(
i => (ei.get(i.code) == null ? i.uses - 1 : ei.get(i.code).uses) < i.uses
);
const daveteden = member.guild.members.cache.get(invite.inviter.id);
db.add(`davet_${invite.inviter.id}_${member.guild.id}`, +1);
db.set(`bunudavet_${member.id}`, invite.inviter.id);
let davetsayiv2 = await db.fetch(
`davet_${invite.inviter.id}_${member.guild.id}`
);
let davetsayi;
if (!davetsayiv2) davetsayi = 0;
else
davetsayi = await db.fetch(
`davet_${invite.inviter.id}_${member.guild.id}`
);
let date = moment(member.user.createdAt)
const startedAt = Date.parse(date);
var msecs = Math.abs(new Date() - startedAt);
const years = Math.floor(msecs / (1000 * 60 * 60 * 24 * 365));
msecs -= years * 1000 * 60 * 60 * 24 * 365;
const months = Math.floor(msecs / (1000 * 60 * 60 * 24 * 30));
msecs -= months * 1000 * 60 * 60 * 24 * 30;
const weeks = Math.floor(msecs / (1000 * 60 * 60 * 24 * 7));
msecs -= weeks * 1000 * 60 * 60 * 24 * 7;
const days = Math.floor(msecs / (1000 * 60 * 60 * 24));
msecs -= days * 1000 * 60 * 60 * 24;
const hours = Math.floor(msecs / (1000 * 60 * 60));
msecs -= hours * 1000 * 60 * 60;
const mins = Math.floor((msecs / (1000 * 60)));
msecs -= mins * 1000 * 60;
const secs = Math.floor(msecs / 1000);
msecs -= secs * 1000;
var string = "";
if (years > 0) string += `${years} yıl ${months} ay`
else if (months > 0) string += `${months} ay ${weeks > 0 ? weeks+" hafta" : ""}`
else if (weeks > 0) string += `${weeks} hafta ${days > 0 ? days+" gün" : ""}`
else if (days > 0) string += `${days} gün ${hours > 0 ? hours+" saat" : ""}`
else if (hours > 0) string += `${hours} saat ${mins > 0 ? mins+" dakika" : ""}`
else if (mins > 0) string += `${mins} dakika ${secs > 0 ? secs+" saniye" : ""}`
else if (secs > 0) string += `${secs} saniye`
string = string.trim();
let guild = member.client.guilds.cache.get(ayarlar.SunucuID)
let log = guild.channels.cache.get(ayarlar.hosgeldinKanal);
let endAt = member.user.createdAt
let gün = moment(new Date(endAt).toISOString()).format('DD')
let ay = moment(new Date(endAt).toISOString()).format('MM').replace("01", "Ocak").replace("02", "Şubat").replace("03", "Mart").replace("04", "Nisan").replace("05", "Mayıs").replace("06", "Haziran").replace("07", "Temmuz").replace("08", "Ağustos").replace("09", "Eylül").replace("10", "Ekim").replace("11", "Kasım").replace("12", "Aralık")
let yıl = moment(new Date(endAt).toISOString()).format('YYYY')
let saat = moment(new Date(endAt).toISOString()).format('HH:mm')
let kuruluş = `${gün} ${ay} ${yıl} ${saat}`;
log.send(`
> :tada: **Adalet #1951** Sunucumuza hoş geldin ${member} seninle birlikte **${member.guild.memberCount}** üyeye ulaştık!
> ** **
> Hesabın **${kuruluş} (${string})** önce oluşturulmuş.
> ** **
> Sunucu kurallarımız <#896409238274965525> kanalında yazıyor sunucu kurallarına uymazsan cezalandırılırsın!
> ** **
> **Davet eden:** ${daveteden} \`${davetsayi}.\` davetini gerçekleştirdi.`)
})});
client.on("guildMemberRemove", async member => {
let davetçi = await db.fetch(`bunudavet_${member.id}`);
const daveteden = member.guild.members.cache.get(davetçi);
db.add(`davet_${davetçi}_${member.guild.id}`, -1);
})

Getting Syntax error in this python code, how to eleminate?

////// section begins /* use this afl when buy is different from cover and sell is different from short / RequestTimedRefresh( 1, onlyvisible = False ) ; _SECTION_BEGIN( "Algoji.com intraday.afl" ); intra = ParamToggle( "Activate Intraday Mode", "NO|YES" ); per10 = Param( "Trade Entry From(HHMM)", 920, 900, 2300, 1 ); per11 = Param( "Trade Entry Upto(HHMM)", 1445, 900, 2300, 1 ); per12 = Param( "Trade Exit(HHMM)", 1515, 900, 2300, 100 ); pop= ParamToggle( "Percentage or Points", "Points|Percentage"); slp = Param( "StopLoss", 0, 0, 1000, 0.1 ); tsl= Param("Trail Stop", 0, 0, 1000, 0.1); tgtp = Param( "Target", 0, 0, 1000, 0.1 ); Col = ParamColor( "Color of Modified Signals", colorYellow ); delay= ParamToggle("Trade Intrabar?", "YES|Candle Completion"); dlong= ParamToggle("Disable Long?", "NO|YES"); dshort= ParamToggle("Disable Short?", "NO|YES"); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} dd= DaysSince1900(); d=prof= 0; if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} qt= Param("Trade Quantity", 0, 0, 1000000) ; exposure= Param("Exposure", 0, 0, 1000000) ; if(exposure>0) qt= round(exposure/ValueWhen(Day()!=Ref(Day(),-1), C)); maxl= Param("Qty using SL (MaxLoss)",0,0,100000 ); if(maxl>0 AND !pop) qt= round(maxl/slp); if(maxl>0 AND pop) { basicprice= LastValue(ValueWhen(Day()!=Ref(Day(),-1), C)); sl= slpbasicprice/100; qt= round(maxl/sl); } intraex = intra AND (TimeNum() > per12 * 100); intraen = !intra OR ( TimeNum() <= per11 * 100 AND TimeNum() >= per10 * 100 ); Buy1 = Buy; Sell1 = Sell; Short1 = Short; Cover1 = Cover; Buy=Sell=Short=Cover=0; bflag = sflag = sp=bp = 0; slarr = tgtarr = qtarr= Null; for ( i = 10; i < BarCount; i++ ) { if ( ( Cover1[i] OR intraex[i]OR( H[i] > slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( L[i] < tgtarr[i-1] AND tgt > 0 ) ) AND sflag ) { Cover[i] = 1; CoverPrice[i]= C[i]; sflag = 0; d= dd[i]; prof= sp-C[i]; } if ( ( Sell1[i] OR intraex[i] OR( L[i] < slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( H[i] > tgtarr[i-1] AND tgt > 0 ) ) AND bflag ) { Sell[i] = 1; SellPrice[i]= C[i]; bflag = 0; d= dd[i]; prof= C[i]- bp; } if ( Buy1[i] AND intraen[i] AND bflag == 0 ) { Buy[i] = 1; bflag = 1; bp= C[i]; sl=slp; tgt= tgtp; if(pop) {sl= slpbp/100; tgt= tgtpbp/100;} if ( slp ) slarr[i] = bp-sl; if ( tgtp ) tgtarr[i] = bp+tgt; } if ( bflag AND Buy[i]==0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Max(slarr[i-1], H[i](1-tsl/100)); if(tsl>0 AND !pop) slarr[i] = Max(slarr[i-1], H[i]-tsl); } if ( Short1[i] AND intraen[i] AND sflag == 0 ) { Short[i] = 1; sflag = 1; Sp= C[i]; sl= slp; tgt= tgtp; if(pop) {sl= slpSp/100; tgt= tgtpSp/100;} if ( slp ) slarr[i] = sp + sl; if ( tgtp ) tgtarr[i] = sp - tgt; } if ( sflag AND Short[i] == 0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Min(slarr[i-1], L[i](1+tsl/100)); if(tsl>0 AND !pop) slarr[i] = Min(slarr[i-1], L[i]+tsl); } } Plot( slarr, "SL", Col, styleThick ); Plot( tgtarr, "TGT", Col, styleThick ); PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), Col, 0, H, Offset = 15 ); PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), Col, 0, L, Offset = 15 ); PlotShapes( IIf( Cover, shapeStar, shapeNone ), Col, 0, H, Offset = -25 ); PlotShapes( IIf( Sell, shapeStar, shapeNone ), Col, 0, L, Offset = -25 ); sig = IIf( BarsSince( Buy ) < BarsSince( Short ), 1, 0 ); messageboard = ParamToggle( "Message Board", "Show|Hide", 1 ); if ( messageboard == 1 ) { GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxSelectSolidBrush( colorDarkTeal ); // this is the box background color pxHeight = Status( "pxchartheight" ) ; xx = Status( "pxchartwidth" ); Left = 1100; width = 310; x = 5; x2 = 310; y = pxHeight; GfxSelectPen( colorGreen, 1 ); // broader color GfxRoundRect( x, y - 160, x2, y , 7, 7 ) ; GfxTextOut( ""+WriteIf(intra, "Intraday Mode Activated", "Intraday Mode Not Activated" ), 13, y-160 ); GfxTextOut( ( "Current Qty "+qt ), 13, y-140 ); GfxTextOut( ( "Last" + " Signal came " + ( BarsSince( Buy OR Short ) ) * Interval() / 60 + " mins ago" ), 13, y - 120 ) ; // The text format location GfxTextOut( ( "" + WriteIf( sig == 1, "BUY # " + ValueWhen(Buy,C) , "SHORT # " + ValueWhen(Short,C) ) ), 13, y - 100 ); GfxTextOut( "Stop Loss : " + WriteIf(slp==0, "Not Activated", ""+slarr), 13, y - 80 ); GfxTextOut( "Target : " + WriteIf(tgtp==0, "Not Activated", ""+tgtarr), 13, y - 60 ); GfxTextOut( ( "Current P/L : " + WriteVal( IIf( sig == 1, (C-ValueWhen(Buy,C))*qt, (ValueWhen(Short,C)-C)*qt ), 2.2 ) ), 13, y-40 ); // GfxTextOut( ( "jhjh " ), 13, y-20 ); } //section begins for auto trade instr= ParamList("Instrument Name","EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCOM"); stag= ParamStr("Strategy Tag", "STG1"); qty= NumToStr(qt[BarCount-1], 1.0, False) ; bp= sp= NumToStr(Close[BarCount-1],1.2, False); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} global algoji; algoji = Name() + NumToStr( Interval() / 60, 1.0, False ) ; procedure aStaticVarSet( SName, Svalue ) { global algoji; StaticVarSet( Sname + algoji, Svalue ); } function aStaticVarGet( SName ) { global algoji; Var = StaticVarGet( Sname + algoji ); if ( IsNull( Var = StaticVarGet( Sname + algoji ) ) ) Var = 0; return Var; } sym = Name(); //_TRACE("t"+t); Checkdt=Nz(aStaticVarGet("lastdt")); dt = LastValue( DateTime() ); Checkdtss=Nz(aStaticVarGet("lastdtss")); dtss = LastValue( DateTime() ); Checkdtc=Nz(aStaticVarGet("lastdtc")); dtc = LastValue( DateTime() ); Checkdts=Nz(aStaticVarGet("lastdts")); dts = LastValue( DateTime() ); RTBuy = LastValue( Buy) AND Checkdt != dt; RTShort = LastValue( Short) AND Checkdtss != dtss; RTCover = LastValue( Cover) AND Checkdtc != dtc; RTSell = LastValue( Sell) AND Checkdts != dts; if ( RTCover ) { aStaticVarSet("lastdtc",dtc ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SX,"+sym+",,," +bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",bp,qty,instr,stag); } if ( RTSell ) { aStaticVarSet("lastdts",dts ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LX,"+sym+",,," +sp +","+qty+",,,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } if ( RTBuy ) { aStaticVarSet("lastdt",dt ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LE,"+sym+",,," +bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",bp,qty,instr,stag); } if ( RTShort ) { aStaticVarSet("lastdtss",dtss ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); sp= NumToStr(Close[BarCount-1],1.2, False); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SE,"+sym+",,," +sp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",bp,qty,instr,stag); } Button = ParamToggle( "Enable Button Trading", "YES|NO" ); expiry= ParamStr("Expiry",""); strike= ParamStr("Strike",""); type= ParamStr("Option Type", ""); sym = Name()+ "|"+expiry+ "|" +strike+ "|" +type; function GetSecondNum() { Time = Now( 4 ); Seconds = int( Time % 100 ); Minutes = int( Time / 100 % 100 ); Hours = int( Time / 10000 % 100 ); SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds ); return SecondNum; } function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top ) { displayText = bodytext + captiontext; if ( ( StaticVarGetText( "prevPopup" + popupID ) != displayText) OR ( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) ) { StaticVarSetText( "prevPopup" + popupID, displayText); StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout ); PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top ); } } x1= Status( "pxchartleft" )+10; y1= Status( "pxcharttop" )+20; if ( Button == 0 ) { click = GetCursorMouseButtons() == 9; Px = GetCursorXPosition( 1 ); Py = GetCursorYPosition( 1 ); x2 = x1 + 60; y2 = y1 + 60; GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) ); //buy GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxRoundRect( x1, y1, x2, y2 , 7, 7 ) ; GfxTextOut( "LE", x1 + 20, y1 + 20 ); sx1 = x2; sy1 = y1; sx2 = sx1 + 60; sy2 = sy1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( sx1, sy1, sx2, sy2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "SE", sx1 + 20, sy1 + 20 ); ex1 = x1; ey1 = y1+60; ex2 = ex1 + 60; ey2 = ey1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( ex1, ey1, ex2, ey2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "LX", ex1 + 20, ey1 + 20 ); GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) );//sell GfxRoundRect( ex2, ey1, ex2+60, ey2 , 7, 7 ) ; GfxSetTextColor( colorWhite ); GfxTextOut( "SX", ex2 + 20, ey1 + 20 ); if ( px > x1 AND pxy1 AND py < y2 AND Click ) { _TRACE( "# ," + NumToStr(Nz(StaticVarGet("counter")),0,False) + ", BUY triggered from button, " ); AlertIf( 1, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 1, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:1", "BUY", "Buy Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > sx1 AND pxsy1 AND py < sy2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SHORT triggered from button, " ); AlertIf( 2, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SHORT", "Short Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex1 AND pxey1 AND py<ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SELL triggered from button, " ); AlertIf( 3, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SELL", "Sell Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex2 AND px<(ex2+60) AND py>ey1 AND py < ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", Cover triggered from button, " ); AlertIf( 4, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "Cover", "Cover Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",sp,qty,instr,stag); } }
It is not a Python, it is AFL. It will be much easier if you post it as a code.
If you run it in AFL Formula Editor it will help you to debug it - simply click "Apply" and you will have all errors highlined.
I've found that you missed some "*" in your formula.

countdown timer doesn't countdown

<script>
var countDownDate = new Date("Jan 1, 2019 00:00:00").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("launch").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
if (distance < 0) {
clearInterval(x);
document.getElementById("launch").innerHTML = "EXPIRED"
}
}, 1000);
</script>

Import many files .txt in SAS

I built a code to import multiple data simultaneously into SAS, but I want to improve it does anyone have any suggestions?
filename indata pipe 'dir E:\Desafio_SAS\Dados /B';
data file_list;
length arquivos$20.;
infile indata truncover ;
input arquivos $20.;
call symput('num_files',_n_);
arquivos=compress(arquivos,',.txt');
run;
CRIANDO UMA MACRO POR PROC SQL PARA GUARDAR O NOME DOS ARQUIVOS
proc sql;
select arquivos into :lista separated by ' ' from file_list;
quit;
%let &lista;
%macro importar(arquivo=);
filename data "E:\Desafio_SAS\Dados\&arquivo..txt";
data &arquivo;
infile data dlm=" " missover dsd firstobs=2;
input v0 (v1 - v8) ($);
format v0 F16.;
run;
%mend importar;
%macro fileout;
%do i=1 %to &num_files;
%importar(arquivo=df&i);
data df&i;
set var_names df&i;
run;
%end;
%mend fileout;
%fileout;
%macro excluiv0;
%do i=1 %to &num_files;
data _null_;
data df&i(drop = v0);
set df&i;
run;
%end;
run;
%mend excluiv0;
%excluiv0;
It's just part of the code.
You can use a wildcard in the infile file-specification. As long as all the files meeting the wildcard are the same layout, you can use a single input to read all the files.
Example
* create three text files having same fields;
data _null_;
file '%temp%\1.txt';
put '1 2 3 abc';
put '3 4 5 def';
file '%temp%\2.txt';
put '6 7 8 ghi';
put '9 10 11 jkl';
file '%temp%\3.txt';
put '12 13 14 xyz';
put '15 16 17 tuv';
run;
* read all three using wildcard in infile. Save name of file whence
* data cometh frometh;
data want;
length _filename_ $250;
infile '%temp%\?.txt' filename=_filename_;
length source $250;
length a b c 8 s $20;
source = _filename_;
input a b c s;
run;
Wildcards are
?, 0 or 1 of any character
*, any number of any character
t1 <- ttheme_default(core=list(
fg_params=list(fontface=c("bold.italic")),
bg_params = list(fill=c("green", "grey90","blue","red"))))
grid.arrange(g1,
tableGrob(iris[1:5, 1:4], theme = t1,, rows=NULL),
g1, g1, nrow = 2)
---
title: "Column Orientation"
output: flexdashboard::flex_dashboard
---
```{r setup, include=FALSE}
library(ggplot2);library(knitr);library(kableExtra)
library(flexdashboard);library(gridExtra);library(grid)
```
<style>
.colored {
background-color: #002080;}
</style>
Column{data-width=200}
-------------------------------------
### Chart 1{.colored}
```{r}
gauge(10, min = 0, max = 100, sectors = gaugeSectors(colors = "#002080"))
gauge(50, min = 0, max = 100, sectors = gaugeSectors(colors = "#002080"))
gauge(20, min = 0, max = 100, sectors = gaugeSectors(colors = "#002080"))
gauge(15, min = 0, max = 100, sectors = gaugeSectors(colors = "#002080"))
gauge(5 , min = 0, max = 100, sectors = gaugeSectors(colors = "#002080"))
```
Column
-------------------------------------
### Chart 2
```{r, include=FALSE}
tt1 <- ttheme_default()
tt2 <- ttheme_minimal()
tt3 <- ttheme_minimal(
core=list(bg_params = list(fill = blues9[1:4], col=NA),
fg_params=list(fontface=3)),
colhead=list(fg_params=list(col="navyblue", fontface=4L)),
rowhead=list(fg_params=list(col="orange", fontface=3L)))
tab <- grid.arrange(tableGrob(iris[c(1:4,1:2), c(1:3,1:2)], theme=tt3), nrow=1)
graf <- ggplot(data=mtcars, aes(x=drat, y=disp, group=vs)) +
geom_line() + ylab("") +
geom_point()
gg.gauge <- function(pos,breaks=c(0,10,25,100)) {
get.poly <- function(a,b,r1=0.5,r2=1.0) {
th.start <- pi*(1-a/100)
th.end <- pi*(1-b/100)
th <- seq(th.start,th.end,length=1000)
x <- c(r1*cos(th),rev(r2*cos(th)))
y <- c(r1*sin(th),rev(r2*sin(th)))
return(data.frame(x,y))
}
ggplot()+
geom_polygon(data=get.poly(breaks[1],breaks[2]),aes(x,y),fill="forestgreen", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(breaks[2],breaks[3]),aes(x,y),fill="gold", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(breaks[3],breaks[4]),aes(x,y),fill="red", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(pos-1,pos+1,0.2),aes(x,y), colour = "white")+
annotate("text",x=0,y=0,label=pos,vjust=0,size=8,fontface="bold")+
coord_fixed()+
theme_bw()+
theme(axis.text=element_blank(),
axis.title=element_blank(),
axis.ticks=element_blank(),
panel.grid=element_blank(),
panel.border=element_blank())
}
gg1 <- gg.gauge(2,breaks=c(0,10,25,100))
gg2 <- gg.gauge(5,breaks=c(0,10,25,100))
gg3 <- gg.gauge(7,breaks=c(0,10,25,100))
```
```{r, fig.width=9.5, fig.height=7}
for (i in 1:5){
title1=textGrob("Test title TESTE", gp=gpar(fontface="bold", fontsize = 15))
lay <- rbind(c(3,3,4,4,5,5),
c(1,1,1,1,1,1),
c(1,1,1,1,1,1),
c(2,2,2,2,2,2),
c(2,2,2,2,2,2))
grid.arrange(graf, tab, gg1, gg2, gg3, top=title1,
layout_matrix= lay)
grid.rect(width = 1, height = 1, gp = gpar(lwd = 2, col = "black", fill = NA))
cat("\n")
}
```
---
title: "BRADESCO"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r setup, include=FALSE}
library(ggplot2);library(knitr);library(kableExtra)
library(flexdashboard);
library(gridExtra);library(grid)
```
Geral {data-icon="fa-signal"}
=====================================
### Chat 1
```{r}
p1 <- qplot(mpg, wt, data = mtcars, colour = cyl)
p2 <- qplot(mpg, data = mtcars)
p3 <- qplot(mpg, data = mtcars, geom = "dotplot")
lay <- rbind(c(1,1,1,2,2,2),
c(3,3,3,3,3,3))
grid.arrange(p2, p3, p1, nrow = 2, layout_matrix= lay)
```
### Table 1
```{r}
kable(mtcars[1:10, c(1:6,1:4)], caption = "Group Rows") %>%
kable_styling("striped", full_width = F) %>%
group_rows("Group 1", 4, 7) %>%
group_rows("Group 2", 8, 10)
```
Por segmento {data-icon="fa-signal"}
=====================================
<style>
.colored {
background-color: #002080;}
</style>
Row{data-height=200}
-------------------------------------
### Chart 1{.colored}
```{r, fig.width=55}
dat = data.frame(count=rep(c(10, 60, 30),10), category=rep(c("A", "B", "C"),10), fator=c(1,2,3,4,5))
# Add addition columns, needed for drawing with geom_rect.
dat$fraction = dat$count / sum(dat$count)
dat = dat[order(dat$fraction), ]
dat$ymax = cumsum(dat$fraction)
dat$ymin = c(0, head(dat$ymax, n=-1))
p <- ggplot(dat, aes(x=2, y=fraction, fill=category))+
geom_bar(stat="identity", colour = "white", size = 2) +
xlim(0, 2.5) +
scale_fill_manual(values=c("#002080", "#002080", "white")) +
coord_polar(theta = "y")+
labs(x=NULL, y=NULL)+ guides(fill=FALSE) +
ylab("fsfagafs") + facet_wrap(~ fator,nrow = 1) +
annotate("text", x = 0, y = 0, label = "WW", size = 20, colour = "white") +
theme(
plot.margin = margin(-1.1, 3.6, -1.1, 3.6, "cm"),
panel.spacing = unit(30, "lines"),
axis.ticks=element_blank(),
axis.text=element_blank(),
axis.title=element_blank(),
panel.grid=element_blank(),
plot.background = element_rect(fill = "#002080", colour="#002080"),
panel.background = element_rect(fill = "#002080", colour="#002080"),
strip.background = element_blank(),
strip.text.x = element_blank())
p
```
Row
-------------------------------------
### Chart 2 {data-wight=900}
```{r, include=FALSE}
tt1 <- ttheme_default()
tt2 <- ttheme_minimal()
tt3 <- ttheme_minimal(
core=list(bg_params = list(fill = blues9[1:4], col=NA),
fg_params=list(fontface=3)),
colhead=list(fg_params=list(col="navyblue", fontface=4L)),
rowhead=list(fg_params=list(col="orange", fontface=3L)))
tab <- grid.arrange(tableGrob(iris[c(1:4,1:2), c(1:3,1:2)], theme=tt3), nrow=1)
graf <- ggplot(data=mtcars, aes(x=drat, y=disp, group=vs)) +
geom_line() + ylab("") +
geom_point()
gg.gauge <- function(pos,breaks=c(0,10,25,100)) {
get.poly <- function(a,b,r1=0.5,r2=1.0) {
th.start <- pi*(1-a/100)
th.end <- pi*(1-b/100)
th <- seq(th.start,th.end,length=1000)
x <- c(r1*cos(th),rev(r2*cos(th)))
y <- c(r1*sin(th),rev(r2*sin(th)))
return(data.frame(x,y))
}
ggplot()+
geom_polygon(data=get.poly(breaks[1],breaks[2]),aes(x,y),fill="forestgreen", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(breaks[2],breaks[3]),aes(x,y),fill="gold", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(breaks[3],breaks[4]),aes(x,y),fill="red", colour = "white", size = 1.2, alpha = 0.7) +
geom_polygon(data=get.poly(pos-1,pos+1,0.2),aes(x,y), colour = "white")+
annotate("text",x=0,y=0,label=pos,vjust=0,size=8,fontface="bold")+
coord_fixed()+
theme_bw()+
theme(axis.text=element_blank(),
axis.title=element_blank(),
axis.ticks=element_blank(),
panel.grid=element_blank(),
panel.border=element_blank())
}
gg1 <- gg.gauge(2,breaks=c(0,10,25,100))
gg2 <- gg.gauge(5,breaks=c(0,10,25,100))
gg3 <- gg.gauge(7,breaks=c(0,10,25,100))
```
```{r, fig.width=7.2, fig.height=7}
for (i in 1:5){
title1=textGrob("Test title TESTE", gp=gpar(fontface="bold", fontsize = 15))
lay <- rbind(c(3,3,4,4,5,5),
c(1,1,1,1,1,1),
c(1,1,1,1,1,1),
c(2,2,2,2,2,2),
c(2,2,2,2,2,2))
grid.arrange(graf, tab, gg1, gg2, gg3, top=title1,
layout_matrix= lay)
grid.rect(width = 1, height = 1, gp = gpar(lwd = 2, col = "black", fill = NA))
cat("\n")
}
```
### Chart 2
```{r}
mydata = data.frame(x1 = c(1,2,3),
x2 = c(9,8,7),
label = c("description a",
"description b",
"description c"))
ht = 5
wd1 = 5
wd2 = 12
gap = 0.1
nc = ncol(mydata)
nr = nrow(mydata)
x = rep(c(seq(0,(nc-2)*(wd1+gap), wd1+gap), (nc-2)*(wd1+gap) + gap + 0.5*(wd2+wd1)), nr)
y = rep(seq(0,(nr-1)*(ht+gap), ht+gap), nc) %>% sort()
h = rep(ht, nr * nc)
w = rep(c(rep(wd1, nc-1), wd2), nr)
info = as.vector(t(as.matrix(mydata[nr:1,])))
df = data.frame(x = x, y = y, h = h, w = w, info = info)
ggplot(df, aes(x, y, height = h, width = w, label = info)) +
geom_tile() +
geom_text(color = "white", fontface = "bold") +
coord_fixed() +
scale_fill_brewer(type = "qual",palette = "Dark2") +
theme_void() +
guides(fill = F)
```
teste

Angularjs split last hour in 10 minutes slices

Is there a way I can take the time between now and last hour and split it in 10 minutes slices in AngularJS? Something like below
10:00:00
09:50:00
09:40:00
09:30:00
09:20:00
09:10:00
09:00:00
The start time code is
//time now -1 hour
$scope.startTime = new Date( (new Date) * 1 - 1000 * 3600 * 1 );
And for end time I am using
//time now
$scope.endTime = new Date();
To make it a genuine date I am using this function
Date.prototype.yyyymmddhhmm = function() {
var yyyy = this.getFullYear();
var mm = this.getMonth() < 9 ? "0" + (this.getMonth() + 1) : (this.getMonth() + 1); // getMonth() is zero-based
var dd = this.getDate() < 10 ? "0" + this.getDate() : this.getDate();
var hh = this.getHours() < 10 ? "0" + this.getHours() : this.getHours();
var min = this.getMinutes() < 10 ? "0" + this.getMinutes() : this.getMinutes();
var sec = this.getSeconds() < 10 ? "0" + this.getSeconds() : this.getSeconds();
return "".concat(yyyy + '-').concat(mm + '-').concat(dd + ' ').concat(hh + ':').concat(min + ':').concat(sec);
};
What I need the 10 minutes slices is for a Line Chart labels.
Thanks
I have modified the code and as below,
js code as below
var myApp = angular.module('myApp',[])
.controller('MyCtrl', function($scope){
$scope.timeList = [];
$scope.seconds = 0;
var time = formatAMPM(new Date( (new Date) * 1 + 1000 * 0 * 1 ));
$scope.timeList.push(time);
for(i=0;i<=5;i++)
{
$scope.seconds = $scope.seconds + 600;
var time = formatAMPM(new Date( (new Date) * 1 + 1000 * $scope.seconds * 1 ));
$scope.timeList.push(time);
}
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
}
});
Html Code as below,
<div ng-controller="MyCtrl">
<div ng-repeat="time in timeList">
{{time}}
</div>
</div>
Check this JSFiddle Link: Demo
OutPut is as below:
3:44 pm
3:54 pm
4:04 pm
4:14 pm
4:24 pm
4:34 pm
4:44 pm
Hope this helps you
Thanks
var endTime = new Date();
var startTime = new Date( endTime.getTime() - 1000 * 3600 );
var time = startTime;
while (time < endTime) {
time = new Date(time.getTime() + 1000 * 60 * 10);
// do something with the generated time
}
This doesn't use anything you didn't already use, I'm confused as to what you got stuck on.

Resources